You've brought a site with an example, haven't you? JS is noted that you can take it directly with the example (although in your case there is a very large code).Look at the HTML page code, see that there are three slides with class. slide in block with id featured-slides-wrapper♪ Let's note that all three slides have z-index - 8, 7, 6.Open the source codes of the page through any instrument of the developer in the browser. We see there's only one interesting js file: main.min.js♪ We'll copy the code in there. http://jsbeautifier.org/ or use a browser formatter in Chrome. We get a readable js.♪ $(document).ready() See a lot of signatures on the event and the abolition of standard behaviour e.preventDefault♪ We'll bet the brjapoin on the event we need, like 'mousewheel'. We're in a function:function b(b) {
var g = b || window.event,
h = i.call(arguments, 1),
j = 0,
k = 0,
l = 0,
m = 0;
if (b = a.event.fix(g), b.type = "mousewheel", "detail" in g && (l = -1 * g.detail), "wheelDelta" in g && (l = g.wheelDelta), "wheelDeltaY" in g && (l = g.wheelDeltaY), "wheelDeltaX" in g && (k = -1 * g.wheelDeltaX), "axis" in g && g.axis === g.HORIZONTAL_AXIS && (k = -1 * l, l = 0), j = 0 === l ? k : l, "deltaY" in g && (l = -1 * g.deltaY, j = l), "deltaX" in g && (k = g.deltaX, 0 === l && (j = -1 * k)), 0 !== l || 0 !== k) {
if (1 === g.deltaMode) {
var n = a.data(this, "mousewheel-line-height");
j *= n, l *= n, k *= n
} else if (2 === g.deltaMode) {
var o = a.data(this, "mousewheel-page-height");
j *= o, l *= o, k *= o
}
return m = Math.max(Math.abs(l), Math.abs(k)), (!f || f > m) && (f = m, d(g, m) && (f /= 40)), d(g, m) && (j /= 40, k /= 40, l /= 40), j = Math[j >= 1 ? "floor" : "ceil"](j / f), k = Math[k >= 1 ? "floor" : "ceil"](k / f), l = Math[l >= 1 ? "floor" : "ceil"](l / f), b.deltaX = k, b.deltaY = l, b.deltaFactor = f, b.deltaMode = 0, h.unshift(b, j, k, l), e && clearTimeout(e), e = setTimeout(c, 200), (a.event.dispatch || a.event.handle).apply(this, h)
}
}
which in turn fails function e(a) {
l = i.scrollTop(),
delta_intent = a.deltaY,
delta_intent > 0 ? g() : f()
}
It's simple using the parameters of the event. mousewheel, determined, wheeled down or up (mother mathematics) and then cause one of the functions f or g♪ Let's see one of them:function g(b) {
if (!p && o.prev().length) {
if (p = !0,
o.removeClass("active"),
o = o.prev().addClass("active").removeClass("old"),
a.find(".dot").eq(o.index()).addClass("active").siblings().removeClass("active"),
"force" === b)
return void (p = !1);
setTimeout(function() {
p = !1
}, 1e3)
}
}
We'll notice that the animation works. removeClass("old")♪ Main class properties old is the characteristic of height: top: 0 !important♪ But if it's just a thing to do, the slide will be gone, but it won't be animation. We need to understand where animation came from.If you're looking, animate You can find that the library is used to animate. https://github.com/tweenjs/tween.js/ ♪ Her connection and construction can be found in the code, but it's a long time. The essence of the library is that it allows for a change of sss properties to be smooth. So when we're cleaning up the "old" class, the top slide is moving smoothly from 0 to standard (exit/takes down) header) Cost z-index If you can see more than one picture now, it's only the right one.Total recipe used:Connect. Tween for animation.The document is downloaded
The wheels, the shooters and the car-washing swab are hanging by processors that prevent standard behaviour.We're making a list of slides with the departing. z-index HTML. We're all in.
the same sss. top and position:absolute♪ Upper slide, we'll see how active♪ We do css-grade. old c top: 0 !important♪In the event of the opening, we hang our processor (in general, there's still a keyboard arrow, a swipe and a right plug, but done the same). The processor sees where the wheel has been drilled and sees if we have more slide. If there is, we'll have the right classes. old♪ active slide and start. Tween♪ If you don't, and the current slide is the last one, we're taking out our pre-emptive standard behavior processors and the page is starting to disappear. If we do, we'll go back. top: 0 (Scroll processor) - the pre-retroversal processors are back up and starting slide.