Skip to content

Commit

Permalink
Swapping passive listener to argument
Browse files Browse the repository at this point in the history
 - Needed for horizontal scroll

TODO: Add to docs
  • Loading branch information
NickPiscitelli committed Apr 28, 2024
1 parent d26e821 commit d364ecd
Show file tree
Hide file tree
Showing 5 changed files with 3,258 additions and 2,229 deletions.
2 changes: 1 addition & 1 deletion docs/assets/js/glider.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions glider.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
slidesToShow: 1,
resizeLock: true,
duration: 0.5,
passiveListeners: false,
// easeInQuad
easing: function (x, t, b, c, d) {
return c * (t /= d) * t + b
Expand Down Expand Up @@ -88,16 +89,11 @@
{
scroll: _.updateControls.bind(_)
},
{ passive: true }
)
_.event(
_window,
'add',
{
resize: _.resize
},
{ passive: true }
{ passive: _.opt.passiveListeners }
)
_.event(_window, 'add', {
resize: _.resize
})
})

var gliderPrototype = Glider.prototype
Expand Down Expand Up @@ -211,7 +207,11 @@

_.ele.classList.toggle('draggable', _.opt.draggable === true)
_.event(_.ele, 'remove', events)
if (_.opt.draggable) _.event(_.ele, 'add', events)
if (_.opt.draggable) {
_.event(_.ele, 'add', events, {
passive: _.opt.passiveListeners
})
}
}

gliderPrototype.buildDots = function () {
Expand Down Expand Up @@ -602,7 +602,7 @@
gliderPrototype.event = function (ele, type, args) {
var eventHandler = ele[type + 'EventListener'].bind(ele)
Object.keys(args).forEach(function (k) {
if (k === 'mousedown' || (k === 'click' && !this.preventClick)) { eventHandler(k, args[k]) } else eventHandler(k, args[k], { passive: true })
eventHandler(k, args[k])
})
}

Expand Down
Loading

0 comments on commit d364ecd

Please sign in to comment.