danielepiccone / ng-pageslide

AngularJS sliding panel for serving additional content from off the page
http://danielepiccone.github.io/ng-pageslide/examples/
451 stars 160 forks source link

start with slider closed if required, to avoid on load slide #167

Closed axar closed 6 years ago

axar commented 7 years ago

The slider was appearing and disappearing on load if psOpen is marked as false on load.

deini commented 7 years ago

@dpiccone Can this get merged 🙏 ?

danielepiccone commented 6 years ago

Hi, can you replicate the issue in a plunkr/jsfiddle?

I don't understand how onload fits into the picture, this looks some sort of initialization code, which should be alredy taken care by the psOpen binding.

axar commented 6 years ago

Pretty much the DOM is added first and then the code runs which means if the code takes longer to run the slider is added the dom in it's open state (probably caused by the router). Then the initSlider code runs and it hides the slider, and causes an animation. By setting the slider to closed position (if required) ensures no late transitions.

If you set a break point on the example.js controller first line, you will see the slider remain open until watch is executed.

After spending couple of hours trying to replicate, I've failed to do so. It seems the watch scope.$watch('psOpen', function(value) { fires late, which leaves the slider open until. If the scope is really busy and the watch fires late should be able to replicate.

danielepiccone commented 6 years ago

I have added a change here https://github.com/danielepiccone/ng-pageslide/commit/2fa5c299304386264577c272a22cf367c29296a1 that should address this problem and, consequently #171