Emit scroll-touch-edge event instead of changing the behavior of scroll-touch-begin/end
fix #6873
This commit is contained in:
		
					parent
					
						
							
								d4b204799d
							
						
					
				
			
			
				commit
				
					
						269a87b26f
					
				
			
		
					 8 changed files with 19 additions and 9 deletions
				
			
		|  | @ -230,6 +230,10 @@ void Window::OnWindowScrollTouchEnd() { | |||
|   Emit("scroll-touch-end"); | ||||
| } | ||||
| 
 | ||||
| void Window::OnWindowScrollTouchEdge() { | ||||
|   Emit("scroll-touch-edge"); | ||||
| } | ||||
| 
 | ||||
| void Window::OnWindowSwipe(const std::string& direction) { | ||||
|   Emit("swipe", direction); | ||||
| } | ||||
|  |  | |||
|  | @ -74,6 +74,7 @@ class Window : public mate::TrackableObject<Window>, | |||
|   void OnWindowMoved() override; | ||||
|   void OnWindowScrollTouchBegin() override; | ||||
|   void OnWindowScrollTouchEnd() override; | ||||
|   void OnWindowScrollTouchEdge() override; | ||||
|   void OnWindowSwipe(const std::string& direction) override; | ||||
|   void OnWindowEnterFullScreen() override; | ||||
|   void OnWindowLeaveFullScreen() override; | ||||
|  |  | |||
|  | @ -504,6 +504,11 @@ void NativeWindow::NotifyWindowScrollTouchEnd() { | |||
|                     OnWindowScrollTouchEnd()); | ||||
| } | ||||
| 
 | ||||
| void NativeWindow::NotifyWindowScrollTouchEdge() { | ||||
|   FOR_EACH_OBSERVER(NativeWindowObserver, observers_, | ||||
|                     OnWindowScrollTouchEdge()); | ||||
| } | ||||
| 
 | ||||
| void NativeWindow::NotifyWindowSwipe(const std::string& direction) { | ||||
|   FOR_EACH_OBSERVER(NativeWindowObserver, observers_, | ||||
|                     OnWindowSwipe(direction)); | ||||
|  |  | |||
|  | @ -207,6 +207,7 @@ class NativeWindow : public base::SupportsUserData, | |||
|   void NotifyWindowMoved(); | ||||
|   void NotifyWindowScrollTouchBegin(); | ||||
|   void NotifyWindowScrollTouchEnd(); | ||||
|   void NotifyWindowScrollTouchEdge(); | ||||
|   void NotifyWindowSwipe(const std::string& direction); | ||||
|   void NotifyWindowEnterFullScreen(); | ||||
|   void NotifyWindowLeaveFullScreen(); | ||||
|  |  | |||
|  | @ -160,9 +160,6 @@ class NativeWindowMac : public NativeWindow, | |||
|   // The "titleBarStyle" option.
 | ||||
|   TitleBarStyle title_bar_style_; | ||||
| 
 | ||||
|   // Whether user has scrolled the page to edge.
 | ||||
|   bool is_edge_; | ||||
| 
 | ||||
|   DISALLOW_COPY_AND_ASSIGN(NativeWindowMac); | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -530,8 +530,7 @@ NativeWindowMac::NativeWindowMac( | |||
|     : NativeWindow(web_contents, options, parent), | ||||
|       is_kiosk_(false), | ||||
|       attention_request_id_(0), | ||||
|       title_bar_style_(NORMAL), | ||||
|       is_edge_(false) { | ||||
|       title_bar_style_(NORMAL) { | ||||
|   int width = 800, height = 600; | ||||
|   options.Get(options::kWidth, &width); | ||||
|   options.Get(options::kHeight, &height); | ||||
|  | @ -676,16 +675,14 @@ NativeWindowMac::NativeWindowMac( | |||
|       if (!web_contents) | ||||
|         return event; | ||||
| 
 | ||||
|       if (!began && is_edge_ && (([event phase] == NSEventPhaseMayBegin) || | ||||
|       if (!began && (([event phase] == NSEventPhaseMayBegin) || | ||||
|                                  ([event phase] == NSEventPhaseBegan))) { | ||||
|         this->NotifyWindowScrollTouchBegin(); | ||||
|         began = YES; | ||||
|         is_edge_ = false; | ||||
|       } else if (began && (([event phase] == NSEventPhaseEnded) || | ||||
|                            ([event phase] == NSEventPhaseCancelled))) { | ||||
|         this->NotifyWindowScrollTouchEnd(); | ||||
|         began = NO; | ||||
|         is_edge_ = false; | ||||
|       } | ||||
|       return event; | ||||
|   }]; | ||||
|  | @ -1131,7 +1128,7 @@ void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) { | |||
|     case blink::WebInputEvent::GestureScrollBegin: | ||||
|     case blink::WebInputEvent::GestureScrollUpdate: | ||||
|     case blink::WebInputEvent::GestureScrollEnd: | ||||
|       is_edge_ = true; | ||||
|         this->NotifyWindowScrollTouchEdge(); | ||||
|       break; | ||||
|     default: | ||||
|       break; | ||||
|  |  | |||
|  | @ -64,6 +64,7 @@ class NativeWindowObserver { | |||
|   virtual void OnWindowMoved() {} | ||||
|   virtual void OnWindowScrollTouchBegin() {} | ||||
|   virtual void OnWindowScrollTouchEnd() {} | ||||
|   virtual void OnWindowScrollTouchEdge() {} | ||||
|   virtual void OnWindowSwipe(const std::string& direction) {} | ||||
|   virtual void OnWindowEnterFullScreen() {} | ||||
|   virtual void OnWindowLeaveFullScreen() {} | ||||
|  |  | |||
|  | @ -448,6 +448,10 @@ Emitted when scroll wheel event phase has begun. | |||
| 
 | ||||
| Emitted when scroll wheel event phase has ended. | ||||
| 
 | ||||
| #### Event: 'scroll-touch-edge' _macOS_ | ||||
| 
 | ||||
| Emitted when scroll wheel event phase filed upon reaching the edge of element. | ||||
| 
 | ||||
| #### Event: 'swipe' _macOS_ | ||||
| 
 | ||||
| Returns: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Anthony Tseng
				Anthony Tseng