angular-responsive-parallax icon indicating copy to clipboard operation
angular-responsive-parallax copied to clipboard

ng-if or template

Open rcanessa89 opened this issue 11 years ago • 9 comments

The module is very cool, but is not working to me when I use inside an element with ng-if or a templete in a state of ui-router

rcanessa89 avatar Oct 02 '15 07:10 rcanessa89

Thank you for opening this issue. Unfortunately I haven't got time at the moment to further develop this repo. If you find a solution though, please let me know!

marcorei avatar Oct 09 '15 12:10 marcorei

Having the same issue myself, I otherwise find this to be the perfect fit for a site I'm building. If I include this in a template it doesn't work, I get an error about TypeError: Cannot read property 'split' of undefined. If I put it directly in my index, it loads fine. I'll post anything I discover in this issue thread.

edencorbin avatar Oct 02 '16 10:10 edencorbin

Hello @edencorbin , thank you for reporting this issue!

I just had time to take a quick look at this. I think the issue consist of:

  • picturefill does not re-run after a new element is inserted via ng-if
  • the animation updates only on scoll and resize

Could you please take a look at this branch and check if this fixes the issue for you? https://github.com/marcorei/angular-responsive-parallax/tree/feature-request-animation-frame

marcorei avatar Oct 03 '16 08:10 marcorei

That did fix it not loading in the template view, it now will load and work without errors. However, if I navigate to a different view, it is not properly cleaned up, I get a glitched version still visible, and the following console error:

angular.js:13920 ReferenceError: onScrollHandler is not defined at P (angular-responsive-parallax.min.js:7) at angular-responsive-parallax.min.js:7 at m.$broadcast (angular.js:18005) at m.$destroy (angular.js:17623) at p (angular-route.js:986) at angular-route.js:1019 at angular.js:8499 at angular.js:8844 at d (angular.js:8637) at m (angular.js:9385)

I'm thinking it needs to be destroyed/cleaned up where I'm changing views, I'll look into this, let me know if you have any ideas or specifically what I should be destroying/cleaning up.

edencorbin avatar Oct 03 '16 11:10 edencorbin

I attempted removing the entire html element prior to switching templates, this didn't fix it, so it's something spawned in the java-script I believe.

edencorbin avatar Oct 03 '16 12:10 edencorbin

You are right! I forgot to remove the onScrollHandler from the destroy function.

marcorei avatar Oct 03 '16 13:10 marcorei

Closer and no errors returning to that template, however, I get the following error going to a different template from the parallax one, maybe my jquery version vs yours?

Error: b.replace is not a function x</ga.matchesSelector@https://code.jquery.com/jquery-3.1.1.min.js:2:12836 r.filter@https://code.jquery.com/jquery-3.1.1.min.js:2:24641 Ja@https://code.jquery.com/jquery-3.1.1.min.js:3:15959 .remove@https://code.jquery.com/jquery-3.1.1.min.js:3:16905 .link/P@http://localhost:8080/js/angular-responsive-parallax.min.js:7:2258 .link/<@http://localhost:8080/js/angular-responsive-parallax.min.js:7:2975 vf/this.$get</m.prototype.$broadcast@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:148:182 vf/this.$get</m.prototype.$destroy@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:144:196 p@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-route.min.js:6:181 B/n<@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-route.min.js:6:454 aa/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:58:109 ac/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:63:37 d@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:59:474 m@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:64:58 B@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-route.min.js:6:362 vf/this.$get</m.prototype.$broadcast@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:148:182 n/<@http://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-route.min.js:11:318 e/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:131:20 vf/this.$get</m.prototype.$eval@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:145:343 vf/this.$get</m.prototype.$digest@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:142:412 vf/this.$get</m.prototype.$apply@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:146:111 Lc[b]</<.compile/</<@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js:276:245 r.event.dispatch@https://code.jquery.com/jquery-3.1.1.min.js:3:10263 r.event.add/q.handle@https://code.jquery.com/jquery-3.1.1.min.js:3:8325

edencorbin avatar Oct 03 '16 13:10 edencorbin

Alright, I had a chance to test it myself with a simple ng-route setup and fixed two more bugs!

marcorei avatar Oct 05 '16 07:10 marcorei

@edencorbin Did this solve your issue?

marcorei avatar Oct 12 '16 05:10 marcorei