Polymer Gestures with drawing HTML5 canvas on multi-platform browsers

82 views
Skip to first unread message

ykar...@gmail.com

unread,
Feb 25, 2015, 6:19:09 AM2/25/15
to polym...@googlegroups.com
Hi,

I work to create custom polymer element for few days now and I try to use Polymer Gestures with drawing HTML5 canvas.

I listen those different events like this :
 var events = [
                    // base events
                    'down',
                    'up',
                    'trackstart',
                    'track',
                    'trackend',
                    'tap',
                    'hold',
                    'holdpulse',
                    'release'
                ];

                this.init();

                events.forEach(function(en) {
                    PolymerGestures.addEventListener(this, en, function (inEvent) {
                        switch (en) {
                            case 'down':
                                this.fire('myscript-canvas-down', {event: inEvent, x : inEvent.x, y : inEvent.y});
                                break;
                            case 'track':
                                this.fire('myscript-canvas-track', {event: inEvent, x : inEvent.x, y : inEvent.y});
                                break;
                            case 'up':
                                this.fire('myscript-canvas-up', {event: inEvent, x : inEvent.x, y : inEvent.y});
                                break;
                        }
                        inEvent.preventDefault();
                    });
                }, this);

But when I'm on the track case, inEvent.x and inEvent.y are undefined.
In fact, the structure of down and up event are the same but the structure of the track event is different. I don't understand why event haven't got an homogeneous structure ?

Please, I need a solution to get the pointer position on the event to draw on my canvas on multi-platform browsers (Firefox, Chrome, etc.).

Thanks
Reply all
Reply to author
Forward
0 new messages