-
Notifications
You must be signed in to change notification settings - Fork 497
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
Active item position and Slidee position isn't restored on sly.reload() #257
Comments
Had the same problem. Here is my solution: if you use the classic new Sly() initialization: then you can use this script to reload the slider without losing the scroll-position:
In case you prefer using the jQuery-proxy: then here is a useful jQuery-extension to refresh the slider:
it can simply be used like this:
|
Update: In certain situations the solution above does not work correctly, i.e. after adding the new Elements using
|
Hi, i am using sly slider, where im into requirement of showing active element visible when page loads intially, user need not to scroll to find active element, i have added startAt:activeElementPosition and itemNav: 'basic',but still its not coming. |
I have really ordinary initialization and logic on Sly, but gotten annoying issue, which I can't solve without hacking into the Sly itself.
I have to recalculate the responsive breakpoints and to update the widths of elements on every window resize, so I'm wiping inline styles on them (alike
$(selector).removeAttr('style')
which Sly applied, and then re-calculating widths for elements and re-applying Sly:it works smoothly, everything is fine, except one huge drawback: in case
slyInstance.rel.activeItem
had something different from zero position, the SLIDEE's position and styles position fortransform: translateZ(0px) translateX(.....)
isn't re-calculated again.So visual appearance in DOM and internal state of slyInstance goes out of sync on
slyInstance.reload()
. That is the SLIDEE has viewport pointing to the zero element after reload, but internallyrel.activeItem
,rel.centerItem
, etc are still having an old values. I think Sly internally has to refresh/update SLIDEE position onreload()
and to recalculate the freshtransform
value for the style as well.I think this code has to be invoked on
reload()
, in the same way is happens oninit
andrender
, here's the code snippet which responsible for that:Separately from that, please, don't forget to return sly instance reference, when
slyInstance.reload()
method is invoked, just to be consistent, and to make possible the further commands chaining.The text was updated successfully, but these errors were encountered: