After and yarn, you can install vf-smooth-scroll with this command. You just need to instantiate a new scroller for that element.A B C Item A With sub–heading Item B With sub–heading Item C With sub–heading Examples Installation info Zenscroll.to(about, 0) // 0 milliseconds = no smoothingĪnything you can do within the document you can also do inside a scrollable DIV or other element. Zenscroll.center(image2, 2000) // 2 seconds Zenscroll.to(about, 500) // 500ms = half a second If you pass a value of zero then the scroll happends immediately, without smoothing.Įxamples: zenscroll.toY(50, 100) // 100ms = 0.1 second You can specifically set the duration for each scroll function via an optional second parameter. The duration is automatically reduced for elements that are very close. The default duration is 999 which is ~1 second. You can work around this by using zenscroll.toY(). Note that a zero value for offset is ignored. Zenscroll.center(image2, duration, offset) (By default offset is the half of the element’s height.) var duration = 500 // milliseconds The top of the element will be upwards from the center of the screen by this amount of pixels. If you want you can also define an offset. Scrolls the element to the center of the screen zenscroll.center(image2) Tip: If you resize an element with a transition of 500ms, you can postpone calling zenscroll with that amount of time: ("is-small")ĥ. If the element is higher than the visible viewport then it will simply scroll to the top of the element, including the edge offset. Otherwise Zenscroll will try to make both top & bottom of element visible, if possible. If the element is already fully visible, with the edge offset at the top and bottom, then no scroll is performed. Scroll to a specific vertical position zenscroll.toY(50) You can globally override the default value by calling tup() (see below), or by providing the edgeOffset parameter when you create a scroller for a DIV, e.g., zenscroll.createScroller(myDiv, null, 20) 3. If you have a fixed navigation bar or footer bar then you probably need more than that. Note that Zenscroll intentionally leaves a few pixels (by default 9px) from the edges of the screen or scrolling container. Scroll to the top of an element var about = document.getElementById("about")
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |