Skip to content
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

Waypoint update broke things! #993

Closed
iamntz opened this issue Dec 6, 2016 · 8 comments
Closed

Waypoint update broke things! #993

iamntz opened this issue Dec 6, 2016 · 8 comments
Labels
bug Indicates a bug with one or multiple components.

Comments

@iamntz
Copy link
Contributor

iamntz commented Dec 6, 2016

It seems that a5912c6 broke the waypoint.js

Here is the fix:

--- a/assets/dev/js/frontend/handlers/counter.js
+++ b/assets/dev/js/frontend/handlers/counter.js
@@ -1,6 +1,6 @@
 module.exports = function( $scoop, $ ) {
        $scoop.find( '.elementor-counter-number' ).waypoint( function() {
-               var $number = $( this );
+               var $number = $( this.element );

                $number.numerator( {
                        duration: $number.data( 'duration' )
diff --git a/assets/dev/js/frontend/handlers/progress.js b/assets/dev/js/frontend/handlers/progress.js
index fefc705..6902fd0 100644
--- a/assets/dev/js/frontend/handlers/progress.js
+++ b/assets/dev/js/frontend/handlers/progress.js
@@ -1,6 +1,6 @@
 module.exports = function( $scoop, $ ) {
        $scoop.find( '.elementor-progress-bar' ).waypoint( function() {
-               var $progressbar = $( this );
+               var $progressbar = $( this.element );

                $progressbar.css( 'width', $progressbar.data( 'max' ) + '%' );
        }, { offset: '90%' } );
@joshmarom
Copy link
Contributor

Hi @iamntz. Thank you for your contribution. Could you please elaborate on what exactly was broken?
We can't really see what's wrong...

@iamntz
Copy link
Contributor Author

iamntz commented Dec 6, 2016

Sure thing. Waypoint.js used to have the element as the context (i.e. this was the element itself).

But they changed and now the context is the Waypoint instance, so this will be Waypoint instance:

When we're inside the handler function the this keyword is a reference to the Waypoint instance. We can use this object to access all the properties and methods in the API. One of the most useful properties is element, the waypoint's DOM element.

the this? section

@kobizz
Copy link
Member

kobizz commented Dec 6, 2016

Ok. First of all, the counter widget is working properly.

Regarding your concern, please note that the use of this as a Waypoint instance, only applies to the handler method, as explained in their official docs.

@iamntz
Copy link
Contributor Author

iamntz commented Dec 6, 2016

I forgot to mention, this is a problem only on the release/1.0.0 branch. On develop works as expected.

You are really expecting that a 2 version upgrade to not breaking anything? 💃

@kobizz
Copy link
Member

kobizz commented Dec 6, 2016

Tested in release/1.0.0 and everything is just fine.

@iamntz
Copy link
Contributor Author

iamntz commented Dec 6, 2016

You should check better though.

var $number = $( this );
// [...]
$number.data( 'duration' )

is not valid using latest version of waypoint.js...

@agusmu
Copy link

agusmu commented Dec 7, 2016

I tried to test it on my Elementor 1.0.0 and I can see that counter widget doesn't work on frontend only, but somehow it works on live editor mode... So, the bug happens on frontend only.

Applying the fix from @iamntz above makes counter widget works again on frontend.

@arielk arielk added the bug Indicates a bug with one or multiple components. label Dec 7, 2016
kobizz added a commit to kobizz/elementor that referenced this issue Dec 7, 2016
@KingYes
Copy link
Member

KingYes commented Dec 7, 2016

Thanks!
We fixed this by this PR: #1007

@KingYes KingYes closed this as completed Dec 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates a bug with one or multiple components.
Projects
None yet
Development

No branches or pull requests

6 participants