Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js

Issue 1995783002: DevTools: Add inertia to flamechart dragging. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix click - call dragEnd immediately if velocity is already below the threshold. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 this._calculator = new WebInspector.FlameChart.Calculator(dataProvider); 67 this._calculator = new WebInspector.FlameChart.Calculator(dataProvider);
68 68
69 this._canvas = this.contentElement.createChild("canvas"); 69 this._canvas = this.contentElement.createChild("canvas");
70 this._canvas.tabIndex = 1; 70 this._canvas.tabIndex = 1;
71 this.setDefaultFocusedElement(this._canvas); 71 this.setDefaultFocusedElement(this._canvas);
72 this._canvas.addEventListener("mousemove", this._onMouseMove.bind(this), fal se); 72 this._canvas.addEventListener("mousemove", this._onMouseMove.bind(this), fal se);
73 this._canvas.addEventListener("mouseout", this._onMouseOut.bind(this), false ); 73 this._canvas.addEventListener("mouseout", this._onMouseOut.bind(this), false );
74 this._canvas.addEventListener("mousewheel", this._onMouseWheel.bind(this), f alse); 74 this._canvas.addEventListener("mousewheel", this._onMouseWheel.bind(this), f alse);
75 this._canvas.addEventListener("click", this._onClick.bind(this), false); 75 this._canvas.addEventListener("click", this._onClick.bind(this), false);
76 this._canvas.addEventListener("keydown", this._onKeyDown.bind(this), false); 76 this._canvas.addEventListener("keydown", this._onKeyDown.bind(this), false);
77 WebInspector.installDragHandle(this._canvas, this._startCanvasDragging.bind( this), this._canvasDragging.bind(this), this._endCanvasDragging.bind(this), "-we bkit-grabbing", null); 77 WebInspector.installInertialDragHandle(this._canvas, this._startCanvasDraggi ng.bind(this), this._canvasDragging.bind(this), this._endCanvasDragging.bind(thi s), "-webkit-grabbing", null);
78 WebInspector.installDragHandle(this._canvas, this._startRangeSelection.bind( this), this._rangeSelectionDragging.bind(this), this._endRangeSelection.bind(thi s), "text", null); 78 WebInspector.installDragHandle(this._canvas, this._startRangeSelection.bind( this), this._rangeSelectionDragging.bind(this), this._endRangeSelection.bind(thi s), "text", null);
79 79
80 this._vScrollElement = this.contentElement.createChild("div", "flame-chart-v -scroll"); 80 this._vScrollElement = this.contentElement.createChild("div", "flame-chart-v -scroll");
81 this._vScrollContent = this._vScrollElement.createChild("div"); 81 this._vScrollContent = this._vScrollElement.createChild("div");
82 this._vScrollElement.addEventListener("scroll", this._onScroll.bind(this), f alse); 82 this._vScrollElement.addEventListener("scroll", this._onScroll.bind(this), f alse);
83 this._scrollTop = 0; 83 this._scrollTop = 0;
84 84
85 this._entryInfo = this.contentElement.createChild("div", "flame-chart-entry- info"); 85 this._entryInfo = this.contentElement.createChild("div", "flame-chart-entry- info");
86 this._markerHighlighElement = this.contentElement.createChild("div", "flame- chart-marker-highlight-element"); 86 this._markerHighlighElement = this.contentElement.createChild("div", "flame- chart-marker-highlight-element");
87 this._highlightElement = this.contentElement.createChild("div", "flame-chart -highlight-element"); 87 this._highlightElement = this.contentElement.createChild("div", "flame-chart -highlight-element");
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 * @param {!MouseEvent} event 625 * @param {!MouseEvent} event
626 */ 626 */
627 _initMaxDragOffset: function(event) 627 _initMaxDragOffset: function(event)
628 { 628 {
629 this._maxDragOffsetSquared = 0; 629 this._maxDragOffsetSquared = 0;
630 this._dragStartX = event.pageX; 630 this._dragStartX = event.pageX;
631 this._dragStartY = event.pageY; 631 this._dragStartY = event.pageY;
632 }, 632 },
633 633
634 /** 634 /**
635 * @param {!MouseEvent} event 635 * @param {number} x
636 * @param {number} y
636 */ 637 */
637 _updateMaxDragOffset: function(event) 638 _updateMaxDragOffset: function(x, y)
638 { 639 {
639 var dx = event.pageX - this._dragStartX; 640 var dx = x - this._dragStartX;
640 var dy = event.pageY - this._dragStartY; 641 var dy = y - this._dragStartY;
641 var dragOffsetSquared = dx * dx + dy * dy; 642 var dragOffsetSquared = dx * dx + dy * dy;
642 this._maxDragOffsetSquared = Math.max(this._maxDragOffsetSquared, dragOf fsetSquared); 643 this._maxDragOffsetSquared = Math.max(this._maxDragOffsetSquared, dragOf fsetSquared);
643 }, 644 },
644 645
645 /** 646 /**
646 * @return {number} 647 * @return {number}
647 */ 648 */
648 _maxDragOffset: function() 649 _maxDragOffset: function()
649 { 650 {
650 return Math.sqrt(this._maxDragOffsetSquared); 651 return Math.sqrt(this._maxDragOffsetSquared);
651 }, 652 },
652 653
653 /** 654 /**
655 * @param {number} x
656 * @param {number} y
654 * @param {!MouseEvent} event 657 * @param {!MouseEvent} event
655 * @return {boolean} 658 * @return {boolean}
656 */ 659 */
657 _startCanvasDragging: function(event) 660 _startCanvasDragging: function(x, y, event)
658 { 661 {
659 if (event.shiftKey) 662 if (event.shiftKey)
660 return false; 663 return false;
661 if (!this._timelineData() || this._timeWindowRight === Infinity) 664 if (!this._timelineData() || this._timeWindowRight === Infinity)
662 return false; 665 return false;
663 this._isDragging = true; 666 this._isDragging = true;
664 this._initMaxDragOffset(event); 667 this._initMaxDragOffset(event);
665 this._dragStartPointX = event.pageX; 668 this._dragStartPointX = x;
666 this._dragStartPointY = event.pageY; 669 this._dragStartPointY = y;
667 this._dragStartScrollTop = this._vScrollElement.scrollTop; 670 this._dragStartScrollTop = this._vScrollElement.scrollTop;
668 this._dragStartWindowLeft = this._timeWindowLeft;
669 this._dragStartWindowRight = this._timeWindowRight;
670 this._canvas.style.cursor = ""; 671 this._canvas.style.cursor = "";
671 this.hideHighlight(); 672 this.hideHighlight();
672 return true; 673 return true;
673 }, 674 },
674 675
675 /** 676 /**
676 * @param {!MouseEvent} event 677 * @param {number} x
678 * @param {number} y
677 */ 679 */
678 _canvasDragging: function(event) 680 _canvasDragging: function(x, y)
679 { 681 {
680 var pixelShift = this._dragStartPointX - event.pageX; 682 var pixelShift = this._dragStartPointX - x;
681 this._dragStartPointX = event.pageX; 683 this._dragStartPointX = x;
682 this._muteAnimation = true; 684 this._muteAnimation = true;
683 this._handlePanGesture(pixelShift * this._pixelToTime); 685 this._handlePanGesture(pixelShift * this._pixelToTime);
684 this._muteAnimation = false; 686 this._muteAnimation = false;
685 687
686 var pixelScroll = this._dragStartPointY - event.pageY; 688 var pixelScroll = this._dragStartPointY - y;
687 this._vScrollElement.scrollTop = this._dragStartScrollTop + pixelScroll; 689 this._vScrollElement.scrollTop = this._dragStartScrollTop + pixelScroll;
688 this._updateMaxDragOffset(event); 690 this._updateMaxDragOffset(x, y);
689 }, 691 },
690 692
691 _endCanvasDragging: function() 693 _endCanvasDragging: function()
692 { 694 {
693 this._isDragging = false; 695 this._isDragging = false;
694 this._updateHighlight(); 696 this._updateHighlight();
695 }, 697 },
696 698
697 /** 699 /**
698 * @param {!MouseEvent} event 700 * @param {!MouseEvent} event
(...skipping 26 matching lines...) Expand all
725 _hideRangeSelection: function() 727 _hideRangeSelection: function()
726 { 728 {
727 this._selectionOverlay.classList.add("hidden"); 729 this._selectionOverlay.classList.add("hidden");
728 }, 730 },
729 731
730 /** 732 /**
731 * @param {!MouseEvent} event 733 * @param {!MouseEvent} event
732 */ 734 */
733 _rangeSelectionDragging: function(event) 735 _rangeSelectionDragging: function(event)
734 { 736 {
735 this._updateMaxDragOffset(event); 737 this._updateMaxDragOffset(event.pageX, event.pageY);
736 var x = Number.constrain(event.pageX + this._selectionOffsetShiftX, 0, t his._offsetWidth); 738 var x = Number.constrain(event.pageX + this._selectionOffsetShiftX, 0, t his._offsetWidth);
737 var start = this._cursorTime(this._selectionStartX); 739 var start = this._cursorTime(this._selectionStartX);
738 var end = this._cursorTime(x); 740 var end = this._cursorTime(x);
739 this._rangeSelectionStart = Math.min(start, end); 741 this._rangeSelectionStart = Math.min(start, end);
740 this._rangeSelectionEnd = Math.max(start, end); 742 this._rangeSelectionEnd = Math.max(start, end);
741 this._updateRangeSelectionOverlay(); 743 this._updateRangeSelectionOverlay();
742 this._flameChartDelegate.updateRangeSelection(this._rangeSelectionStart, this._rangeSelectionEnd); 744 this._flameChartDelegate.updateRangeSelection(this._rangeSelectionStart, this._rangeSelectionEnd);
743 }, 745 },
744 746
745 _updateRangeSelectionOverlay: function() 747 _updateRangeSelectionOverlay: function()
(...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 this.update(); 2005 this.update();
2004 }, 2006 },
2005 2007
2006 _enabled: function() 2008 _enabled: function()
2007 { 2009 {
2008 return this._rawTimelineDataLength !== 0; 2010 return this._rawTimelineDataLength !== 0;
2009 }, 2011 },
2010 2012
2011 __proto__: WebInspector.HBox.prototype 2013 __proto__: WebInspector.HBox.prototype
2012 } 2014 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698