js/materialize.clockpicker.js
function mousedown(e, space) {
            var offset = plate.offset(),
                isTouch = /^touch/.test(e.type),
                x0 = offset.left + dialRadius,
                y0 = offset.top + dialRadius,
                dx = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
                dy = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0,
                z = Math.sqrt(dx * dx + dy * dy),
                moved = false;

            // When clicking on minutes view space, check the mouse position
            if (space && (z < outerRadius - tickRadius || z > outerRadius + tickRadius))
                return;
            e.preventDefault();

            // Set cursor style of body after 200ms
            var movingTimer = setTimeout(function(){
                self.popover.addClass('clockpicker-moving');
            }, 200);

            // Place the canvas to top
            if (svgSupported)
                plate.append(self.canvas);

            // Clock
            self.setHand(dx, dy, !space, true);

            // Mousemove on document
            $doc.off(mousemoveEvent).on(mousemoveEvent, function(e){
                e.preventDefault();
                var isTouch = /^touch/.test(e.type),
                    x = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
                    y = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0;
                if (! moved && x === dx && y === dy)
                // Clicking in chrome on windows will trigger a mousemove event
                    return;
                moved = true;
                self.setHand(x, y, false, true);
            });

            // Mouseup on document
            $doc.off(mouseupEvent).on(mouseupEvent, function(e) {
                $doc.off(mouseupEvent);
                e.preventDefault();
                var isTouch = /^touch/.test(e.type),
                    x = (isTouch ? e.originalEvent.changedTouches[0] : e).pageX - x0,
                    y = (isTouch ? e.originalEvent.changedTouches[0] : e).pageY - y0;
                if ((space || moved) && x === dx && y === dy)
                    self.setHand(x, y);
                if (self.currentView === 'hours')
                    self.toggleView('minutes', duration / 2);
                else
                if (options.autoclose) {
                    self.minutesView.addClass('clockpicker-dial-out');
                    setTimeout(function(){
                        self.done();
                    }, duration / 2);
                }
                plate.prepend(canvas);

                // Reset cursor style of body
                clearTimeout(movingTimer);
                self.popover.removeClass('clockpicker-moving');

                // Unbind mousemove event
                $doc.off(mousemoveEvent);
            });
        }
function mousedown(e, space) {
            var offset = plate.offset(),
                isTouch = /^touch/.test(e.type),
                x0 = offset.left + dialRadius,
                y0 = offset.top + dialRadius,
                dx = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
                dy = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0,
                z = Math.sqrt(dx * dx + dy * dy),
                moved = false;

            // When clicking on minutes view space, check the mouse position
            if (space && (z < outerRadius - tickRadius || z > outerRadius + tickRadius))
                return;
            e.preventDefault();

            // Set cursor style of body after 200ms
            var movingTimer = setTimeout(function(){
                self.popover.addClass('clockpicker-moving');
            }, 200);

            // Place the canvas to top
            if (svgSupported)
                plate.append(self.canvas);

            // Clock
            self.setHand(dx, dy, !space, true);

            // Mousemove on document
            $doc.off(mousemoveEvent).on(mousemoveEvent, function(e){
                e.preventDefault();
                var isTouch = /^touch/.test(e.type),
                    x = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
                    y = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0;
                if (! moved && x === dx && y === dy)
                // Clicking in chrome on windows will trigger a mousemove event
                    return;
                moved = true;
                self.setHand(x, y, false, true);
            });

            // Mouseup on document
            $doc.off(mouseupEvent).on(mouseupEvent, function(e) {
                $doc.off(mouseupEvent);
                e.preventDefault();
                var isTouch = /^touch/.test(e.type),
                    x = (isTouch ? e.originalEvent.changedTouches[0] : e).pageX - x0,
                    y = (isTouch ? e.originalEvent.changedTouches[0] : e).pageY - y0;
                if ((space || moved) && x === dx && y === dy)
                    self.setHand(x, y);
                if (self.currentView === 'hours')
                    self.toggleView('minutes', duration / 2);
                else
                if (options.autoclose) {
                    self.minutesView.addClass('clockpicker-dial-out');
                    setTimeout(function(){
                        self.done();
                    }, duration / 2);
                }
                plate.prepend(canvas);

                // Reset cursor style of body
                clearTimeout(movingTimer);
                self.popover.removeClass('clockpicker-moving');

                // Unbind mousemove event
                $doc.off(mousemoveEvent);
            });
        }
function mousedown ( e , space ) { var offset = plate . offset ( ) , isTouch = / ^touch / . test ( e . type ) , x0 = offset . left + dialRadius , y0 = offset . top + dialRadius , dx = ( isTouch ? e . originalEvent . touches [ 0 ] : e ) . pageX - x0 , dy = ( isTouch ? e . originalEvent . touches [ 0 ] : e ) . pageY - y0 , z = Math . sqrt ( dx * dx + dy * dy ) , moved = false ; // When clicking on minutes view space, check the mouse position if ( space && ( z < outerRadius - tickRadius || z > outerRadius + tickRadius ) ) return ; e . preventDefault ( ) ; // Set cursor style of body after 200ms var movingTimer = setTimeout ( function ( ) { self . popover . addClass ( 'clockpicker-moving' ) ; } , 200 ) ; // Place the canvas to top if ( svgSupported ) plate . append ( self . canvas ) ; // Clock self . setHand ( dx , dy , ! space , true ) ; // Mousemove on document $doc . off ( mousemoveEvent ) . on ( mousemoveEvent , function ( e ) { e . preventDefault ( ) ; var isTouch = / ^touch / . test ( e . type ) , x = ( isTouch ? e . originalEvent . touches [ 0 ] : e ) . pageX - x0 , y = ( isTouch ? e . originalEvent . touches [ 0 ] : e ) . pageY - y0 ; if ( ! moved && x === dx && y === dy ) // Clicking in chrome on windows will trigger a mousemove event return ; moved = true ; self . setHand ( x , y , false , true ) ; } ) ; // Mouseup on document $doc . off ( mouseupEvent ) . on ( mouseupEvent , function ( e ) { $doc . off ( mouseupEvent ) ; e . preventDefault ( ) ; var isTouch = / ^touch / . test ( e . type ) , x = ( isTouch ? e . originalEvent . changedTouches [ 0 ] : e ) . pageX - x0 , y = ( isTouch ? e . originalEvent . changedTouches [ 0 ] : e ) . pageY - y0 ; if ( ( space || moved ) && x === dx && y === dy ) self . setHand ( x , y ) ; if ( self . currentView === 'hours' ) self . toggleView ( 'minutes' , duration / 2 ) ; else if ( options . autoclose ) { self . minutesView . addClass ( 'clockpicker-dial-out' ) ; setTimeout ( function ( ) { self . done ( ) ; } , duration / 2 ) ; } plate . prepend ( canvas ) ; // Reset cursor style of body clearTimeout ( movingTimer ) ; self . popover . removeClass ( 'clockpicker-moving' ) ; // Unbind mousemove event $doc . off ( mousemoveEvent ) ; } ) ; }
Mousedown or touchstart
Mousedown or touchstart