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

PsOpen & PsClose Bug effects PsSize #105

Closed acalfo closed 8 years ago

acalfo commented 8 years ago

PsOpen's first conditional:

if (slider.style.width !== 0) {

&& PsClose's first conditional:

if (slider && slider.style.width !== 0) {

are both bugs. Notice how you set width to '0px' in the psClose function's switch statement. Thus the conditional check should be !== '0px'

This breaks the functionality around psSize. When I dynamically change the size the psOpen function is always called (because of PsSize's watcher).

This causes changes in size when the pageslider is closed to open it to a blank view - because the current width = '0px' which !== 0. Hopefully a fix will get in soon but until then i'll just have to roll my own version of this handly pageslider.

Thanks,

acalfo commented 8 years ago

Scratch that, didn't realize you were initializing everything to 0 and then checking for init data in those spots. In case anyone else needs it I solved this by modifying the watch method for psSize to:

$scope.$watch('psSize', function(newValue, oldValue) { if (oldValue !== newValue) { param.size = newValue; if ($scope.psOpen) { psOpen(slider, param); } } }); @dpiccone did you intentionally make it so changes in size always open up the slider? Or would it be possible to get this code baked into the package?

Thanks!

danielepiccone commented 8 years ago

No, and originally the size was not meant to be changed dynamically but as a simple configuration parameter.

I don't think the pageslide should do anything when changing ps-size, except changing the size. I'll add your solution as it's backward compatible with the current api and fixes the problem.

danielepiccone commented 8 years ago

available on 1.2.7