@@ -1181,6 +1181,7 @@ def _get_style(self, style: VisualStyle | str) -> VisualStyle:
11811181 """
11821182 if isinstance (style , VisualStyle ):
11831183 return style
1184+ visual_style = VisualStyle .null ()
11841185 if style .startswith ("." ):
11851186 for node in self .ancestors_with_self :
11861187 if not isinstance (node , Widget ):
@@ -1196,7 +1197,7 @@ def _get_style(self, style: VisualStyle | str) -> VisualStyle:
11961197 try :
11971198 visual_style = VisualStyle .parse (style )
11981199 except Exception :
1199- visual_style = VisualStyle . null ()
1200+ pass
12001201 return visual_style
12011202
12021203 @overload
@@ -2542,6 +2543,7 @@ def _scroll_to(
25422543 force : bool = False ,
25432544 on_complete : CallbackType | None = None ,
25442545 level : AnimationLevel = "basic" ,
2546+ release_anchor : bool = True ,
25452547 ) -> bool :
25462548 """Scroll to a given (absolute) coordinate, optionally animating.
25472549
@@ -2555,10 +2557,13 @@ def _scroll_to(
25552557 force: Force scrolling even when prohibited by overflow styling.
25562558 on_complete: A callable to invoke when the animation is finished.
25572559 level: Minimum level required for the animation to take place (inclusive).
2560+ release_anchor: If `True` call `release_anchor`.
25582561
25592562 Returns:
25602563 `True` if the scroll position changed, otherwise `False`.
25612564 """
2565+ if release_anchor :
2566+ self .release_anchor ()
25622567 maybe_scroll_x = x is not None and (self .allow_horizontal_scroll or force )
25632568 maybe_scroll_y = y is not None and (self .allow_vertical_scroll or force )
25642569 scrolled_x = scrolled_y = False
@@ -2676,6 +2681,7 @@ def scroll_to(
26762681 on_complete : CallbackType | None = None ,
26772682 level : AnimationLevel = "basic" ,
26782683 immediate : bool = False ,
2684+ release_anchor : bool = True ,
26792685 ) -> None :
26802686 """Scroll to a given (absolute) coordinate, optionally animating.
26812687
@@ -2691,10 +2697,13 @@ def scroll_to(
26912697 level: Minimum level required for the animation to take place (inclusive).
26922698 immediate: If `False` the scroll will be deferred until after a screen refresh,
26932699 set to `True` to scroll immediately.
2700+ release_anchor: If `True` call `release_anchor`.
26942701
26952702 Note:
26962703 The call to scroll is made after the next refresh.
26972704 """
2705+ if release_anchor :
2706+ self .release_anchor ()
26982707 animator = self .app .animator
26992708 if x is not None :
27002709 animator .force_stop_animation (self , "scroll_x" )
@@ -2869,6 +2878,7 @@ def _lazily_scroll_end() -> None:
28692878 force = force ,
28702879 on_complete = scroll_end_on_complete ,
28712880 level = level ,
2881+ release_anchor = False ,
28722882 )
28732883
28742884 if self ._anchored and self ._anchor_released :
@@ -4548,54 +4558,45 @@ def _on_blur(self, event: events.Blur) -> None:
45484558 def _on_mouse_scroll_down (self , event : events .MouseScrollDown ) -> None :
45494559 if event .ctrl or event .shift :
45504560 if self .allow_horizontal_scroll :
4551- self .release_anchor ()
45524561 if self ._scroll_right_for_pointer (animate = False ):
45534562 event .stop ()
45544563 else :
45554564 if self .allow_vertical_scroll :
4556- self .release_anchor ()
45574565 if self ._scroll_down_for_pointer (animate = False ):
45584566 event .stop ()
45594567
45604568 def _on_mouse_scroll_up (self , event : events .MouseScrollUp ) -> None :
45614569 if event .ctrl or event .shift :
45624570 if self .allow_horizontal_scroll :
4563- self .release_anchor ()
45644571 if self ._scroll_left_for_pointer (animate = False ):
45654572 event .stop ()
45664573 else :
45674574 if self .allow_vertical_scroll :
4568- self .release_anchor ()
45694575 if self ._scroll_up_for_pointer (animate = False ):
45704576 event .stop ()
45714577
45724578 def _on_scroll_to (self , message : ScrollTo ) -> None :
45734579 if self ._allow_scroll :
4574- self .release_anchor ()
45754580 self .scroll_to (message .x , message .y , animate = message .animate , duration = 0.1 )
45764581 message .stop ()
45774582
45784583 def _on_scroll_up (self , event : ScrollUp ) -> None :
45794584 if self .allow_vertical_scroll :
4580- self .release_anchor ()
45814585 self .scroll_page_up ()
45824586 event .stop ()
45834587
45844588 def _on_scroll_down (self , event : ScrollDown ) -> None :
45854589 if self .allow_vertical_scroll :
4586- self .release_anchor ()
45874590 self .scroll_page_down ()
45884591 event .stop ()
45894592
45904593 def _on_scroll_left (self , event : ScrollLeft ) -> None :
45914594 if self .allow_horizontal_scroll :
4592- self .release_anchor ()
45934595 self .scroll_page_left ()
45944596 event .stop ()
45954597
45964598 def _on_scroll_right (self , event : ScrollRight ) -> None :
45974599 if self .allow_horizontal_scroll :
4598- self .release_anchor ()
45994600 self .scroll_page_right ()
46004601 event .stop ()
46014602
@@ -4623,7 +4624,6 @@ def _on_unmount(self) -> None:
46234624 def action_scroll_home (self ) -> None :
46244625 if not self ._allow_scroll :
46254626 raise SkipAction ()
4626- self .release_anchor ()
46274627 self .scroll_home (x_axis = self .scroll_y == 0 )
46284628
46294629 def action_scroll_end (self ) -> None :
@@ -4634,49 +4634,41 @@ def action_scroll_end(self) -> None:
46344634 def action_scroll_left (self ) -> None :
46354635 if not self .allow_horizontal_scroll :
46364636 raise SkipAction ()
4637- self .release_anchor ()
46384637 self .scroll_left ()
46394638
46404639 def action_scroll_right (self ) -> None :
46414640 if not self .allow_horizontal_scroll :
46424641 raise SkipAction ()
4643- self .release_anchor ()
46444642 self .scroll_right ()
46454643
46464644 def action_scroll_up (self ) -> None :
46474645 if not self .allow_vertical_scroll :
46484646 raise SkipAction ()
4649- self .release_anchor ()
46504647 self .scroll_up ()
46514648
46524649 def action_scroll_down (self ) -> None :
46534650 if not self .allow_vertical_scroll :
46544651 raise SkipAction ()
4655- self .release_anchor ()
46564652 self .scroll_down ()
46574653
46584654 def action_page_down (self ) -> None :
46594655 if not self .allow_vertical_scroll :
46604656 raise SkipAction ()
4661- self .release_anchor ()
46624657 self .scroll_page_down ()
46634658
46644659 def action_page_up (self ) -> None :
46654660 if not self .allow_vertical_scroll :
46664661 raise SkipAction ()
4667- self .release_anchor ()
46684662 self .scroll_page_up ()
46694663
46704664 def action_page_left (self ) -> None :
46714665 if not self .allow_horizontal_scroll :
46724666 raise SkipAction ()
4673- self .release_anchor ()
46744667 self .scroll_page_left ()
46754668
46764669 def action_page_right (self ) -> None :
46774670 if not self .allow_horizontal_scroll :
46784671 raise SkipAction ()
4679- self .release_anchor ()
46804672 self .scroll_page_right ()
46814673
46824674 def notify (
0 commit comments