google-code-export / slideshow

Automatically exported from code.google.com/p/slideshow
0 stars 1 forks source link

Controller controls all slideshows on page #232

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?
1. Create page with more than one slideshow
2. Set controller on one slideshow to true, and false on the other
3. Press any enabled keyboard keys, and all slideshows are affected

What is the expected output? What do you see instead?
Only slideshows having controller:true should be affected

What version of the product are you using? On what operating system and
browser?
Latest version, all browsers affected

Please provide any additional information below.

Original issue reported on code.google.com by adriaan....@gmail.com on 7 May 2012 at 11:52

GoogleCodeExporter commented 9 years ago
Never mind, I fixed it by creating a new option: useKB

And added this if statement around the keyboard event delegation:
if (this.options.useKB) {
this.events = $H({
                'keydown': [],
                'keyup': [],
                'mousemove': []
            });
            var keyup = function(e){
                switch(e.key){
                    case 'left':
                        this.prev(e.shift);
                        break;
                    case 'right':
                        this.next(e.shift);
                        break;
                    case 'p':
                        this.pause();
                        break;
                }
            }.bind(this);
            this.events.keyup.push(keyup);
            document.addEvent('keyup', keyup);
}

Original comment by adriaan....@gmail.com on 7 May 2012 at 11:58