Skip to content
This repository has been archived by the owner on Aug 21, 2019. It is now read-only.

click event is fired two times #1

Open
dvyskoc opened this issue Feb 16, 2015 · 6 comments
Open

click event is fired two times #1

dvyskoc opened this issue Feb 16, 2015 · 6 comments

Comments

@dvyskoc
Copy link

dvyskoc commented Feb 16, 2015

Check line 11 - this.on('click', this.onClick);
It is redundant. onClick function will run even without it. Currently click event is fired two times when button is clicked.

@hexylena
Copy link
Owner

nice catch, thanks @DanielVyskoc. should be fixed now.

@Cylix
Copy link

Cylix commented Jun 18, 2015

Hi,

Without this line, buttons are not clickable and your plugin is not usable.
I'm on google-chrome 43 with videoJS 4.11 (I've also tried on 4.12 4.12.9).

hexylena pushed a commit that referenced this issue Jun 18, 2015
After testing confirmed that this really did break my plugin
having to revert it
@hexylena
Copy link
Owner

Hi @Cylix, thanks for spotting this. You're absolutely correct... I should've tested that more extensively. I've already pushed the fix of re-adding this line, and I'll push some more updates today. Thanks again!

@dvyskoc
Copy link
Author

dvyskoc commented Jun 21, 2015

Hi, I was using video.dev.js (probably by mistake) back then. With "normal" minimalised version it is working as it should. I am not sure why it is working differently with dev version, but you can try it too. It is same with dev 4.12.7, executing onClick two times.

@hexylena
Copy link
Owner

... oh, great. More complicated than I thought. I'll try out both and see
what I can do, maybe it's upstream's fault.

Thanks for these comments, y'all.
20. jun. 2015 20.16 skrev "Daniel Vyskoč" notifications@github.com:

Hi, I was using video.dev.js (probably by mistake) back then. With
"normal" minimalised version it is working as it should. I am not sure why
it is working differently with dev version, but you can try it too. It is
same with dev 4.12.7, executing onClick two times.


Reply to this email directly or view it on GitHub
#1 (comment)
.

@hexylena hexylena reopened this Jun 23, 2015
@fjdiazt
Copy link

fjdiazt commented Jun 20, 2017

This is related to #6 and #7, the correct way to handle clicks is not calling onClick, but using the handleClick method, like so

var FBFButton = videojs.extend(VjsButton, {
    constructor: function(player, options) {
        VjsButton.call(this, player, options);
        this.player = player;
        this.frameTime = 1/options.fps;
        this.step_size = options.value;
    },

    handleClick:function() {
        // Start by pausing the player
        this.player.pause();
        // Calculate movement distance
        var dist = this.frameTime * this.step_size;
        this.player.currentTime(this.player.currentTime() + dist);
    }
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants