Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue 144 #146

Merged
merged 5 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.config
.npm
/*~
27 changes: 14 additions & 13 deletions glider.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
)

// set defaults
_.animate_id = _.page = _.slide = 0
_.animate_id = _.page = _.slide = _.scrollLeft = 0
_.arrows = {}

// preserve original options to
Expand Down Expand Up @@ -100,6 +100,7 @@

_.slides = _.track.children;


[].forEach.call(_.slides, function (_, i) {
_.classList.add('glider-slide')
_.setAttribute('data-gslide', i)
Expand Down Expand Up @@ -265,14 +266,14 @@
if (_.arrows.next) {
_.arrows.next.classList.toggle(
'disabled',
Math.ceil(_.ele.scrollLeft + _.containerWidth) >=
Math.ceil(_.scrollLeft + _.containerWidth) >=
Math.floor(_.trackWidth) || disableArrows
)
}
}

_.slide = Math.round(_.ele.scrollLeft / _.itemWidth)
_.page = Math.round(_.ele.scrollLeft / _.containerWidth)
_.slide = Math.round(_.scrollLeft / _.itemWidth)
_.page = Math.round(_.scrollLeft / _.containerWidth)

var middle = _.slide + Math.floor(Math.floor(_.opt.slidesToShow) / 2)

Expand All @@ -283,7 +284,7 @@

// the last page may be less than one half of a normal page width so
// the page is rounded down. when at the end, force the page to turn
if (_.ele.scrollLeft + _.containerWidth >= Math.floor(_.trackWidth)) {
if (_.scrollLeft + _.containerWidth >= Math.floor(_.trackWidth)) {
_.page = _.dots ? _.dots.children.length - 1 : 0
}

Expand All @@ -292,9 +293,9 @@

var wasVisible = slideClasses.contains('visible')

var start = _.ele.scrollLeft
var start = _.scrollLeft

var end = _.ele.scrollLeft + _.containerWidth
var end = _.scrollLeft + _.containerWidth

var itemStart = _.itemWidth * index

Expand Down Expand Up @@ -451,14 +452,13 @@

var animate = function () {
var now = new Date().getTime() - start
_.ele.scrollLeft =
_.ele.scrollLeft +
(scrollTarget - _.ele.scrollLeft) *
_.opt.easing(0, now, 0, 1, scrollDuration)
_.scrollLeft = _.scrollLeft + (scrollTarget - _.scrollLeft) * _.opt.easing(0, now, 0, 1, scrollDuration)
_.ele.scrollLeft = _.scrollLeft

if (now < scrollDuration && animateIndex === _.animate_id) {
_window.requestAnimationFrame(animate)
} else {
_.ele.scrollLeft = scrollTarget
_.ele.scrollLeft = _.scrollLeft = scrollTarget
callback && callback.call(_)
}
}
Expand Down Expand Up @@ -488,9 +488,10 @@
var _ = this
if (_.mouseDown) {
_.isDrag = true
_.ele.scrollLeft +=
_.scrollLeft +=
(_.mouseDown - e.clientX) * (_.opt.dragVelocity || 3.3)
_.mouseDown = e.clientX
_.ele.scrollLeft = _.scrollLeft
}
}

Expand Down
2 changes: 1 addition & 1 deletion glider.min.js

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