In a case, I want to【关注微信公众号:wwwtangshuangnet】转载请注明出处:www.tangshuang.net sync scrollbar acti【转载请注明来源】【本文首发于唐霜的博客】on between different【关注微信公众号:wwwtangshuangnet】【未经授权禁止转载】 element by jquery. 【未经授权禁止转载】【转载请注明来源】For example, when sc【转载请注明来源】【本文受版权保护】roll $a’s scro本文作者:唐霜,转载请注明出处。原创内容,盗版必究。llbar, or mouse whee未经授权,禁止复制转载。【本文受版权保护】l scroll down on $a,未经授权,禁止复制转载。转载请注明出处:www.tangshuang.net I want to scroll $b本文版权归作者所有,未经授权不得转载。【版权所有】唐霜 www.tangshuang.net’s scrollbar, 本文版权归作者所有,未经授权不得转载。转载请注明出处:www.tangshuang.netor even scrollTop/sc本文作者:唐霜,转载请注明出处。【原创不易,请尊重版权】rollLeft when $b is 【转载请注明来源】【访问 www.tangshuang.net 获取更多精彩内容】overflow:hidden. Now原创内容,盗版必究。原创内容,盗版必究。 let’s do it:
著作权归作者所有,禁止商业用途转载。【版权所有,侵权必究】【作者:唐霜】【未经授权禁止转载】let syncScrollTopA2B = ($a, $b) => {
$a.on('scroll', function() {
$b.scrollTop($a.scrollTop())
})
}
let syncMousewheelTopA2B = ($a, $b) => {
$a.on('mousewheel DOMMouseScroll', function(e) {
let { deltaY } = e.originalEvent
$a.scrollTop($a.scrollTop() + deltaY)
$b.scrollTop($a.scrollTop())
})
}
let syncTop = ($a, $b) => {
syncScrollTopA2B($a, $b)
syncMousewheelTopA2B($b, $a)
}
let syncScrollLeftA2B = ($a, $b) => {
$a.on('scroll', function() {
$b.scrollLeft($a.scrollLeft())
})
}
let syncMousewheelLeftA2B = ($a, $b) => {
$a.on('mousewheel DOMMouseScroll', function(e) {
if (e.shiftKey) { // press shift key on your keyboard
let { deltaX } = e.originalEvent
$a.scrollLeft($a.scrollLeft() + deltaX)
$b.scrollLeft($a.scrollLeft())
}
})
}
let syncLeft = ($a, $b) => {
syncScrollLeftA2B($a, $b)
syncMousewheelLeftA2B($b, $a)
}
When pull scrollbar 【关注微信公众号:wwwtangshuangnet】本文作者:唐霜,转载请注明出处。on $a, scrollTop wil【访问 www.tangshuang.net 获取更多精彩内容】原创内容,盗版必究。l sync to $b. The sa【版权所有】唐霜 www.tangshuang.net【本文首发于唐霜的博客】me with mouse wheel 【关注微信公众号:wwwtangshuangnet】转载请注明出处:www.tangshuang.netevent. However, hori【本文受版权保护】原创内容,盗版必究。zontal mouse wheel e原创内容,盗版必究。本文版权归作者所有,未经授权不得转载。vent is different, y转载请注明出处:www.tangshuang.net著作权归作者所有,禁止商业用途转载。ou should press shift on your keyboard at著作权归作者所有,禁止商业用途转载。【访问 www.tangshuang.net 获取更多精彩内容】 the same time.


