mirror of https://github.com/anoshenko/rui.git
Added ScrollIntoViewIfNeeded function
This commit is contained in:
parent
991f87e4b1
commit
6c84f332aa
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
* Removed "style-disabled" property and GetDisabledStyle function
|
* Removed "style-disabled" property and GetDisabledStyle function
|
||||||
* Added GoogleFonts field to AppParams
|
* Added GoogleFonts field to AppParams
|
||||||
* Added functions: GetWhiteSpace, GetWordBreak
|
* Added functions: GetWhiteSpace, GetWordBreak, ScrollIntoViewIfNeeded
|
||||||
|
|
||||||
# v0.20.0
|
# v0.20.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1280,6 +1280,17 @@ function scrollToEnd(elementId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scrollIntoViewIfNeeded(elementId) {
|
||||||
|
const element = document.getElementById(elementId);
|
||||||
|
if (element) {
|
||||||
|
if (element.scrollIntoViewIfNeeded) {
|
||||||
|
element.scrollIntoViewIfNeeded()
|
||||||
|
} else {
|
||||||
|
element.scrollIntoView({block: "nearest", inline: "nearest"});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function focus(elementId) {
|
function focus(elementId) {
|
||||||
const element = document.getElementById(elementId);
|
const element = document.getElementById(elementId);
|
||||||
if (element) {
|
if (element) {
|
||||||
|
|
|
||||||
|
|
@ -100,3 +100,14 @@ func ScrollViewToEnd(view View, subviewID ...string) {
|
||||||
view.Session().callFunc("scrollToEnd", view.htmlID())
|
view.Session().callFunc("scrollToEnd", view.htmlID())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ScrollIntoViewIfNeeded scrolls the current view into the visible area of the browser window if it's not already within the visible area of the browser window.
|
||||||
|
// If the element is already within the visible area of the browser window, then no scrolling takes place.
|
||||||
|
//
|
||||||
|
// The second argument (subviewID) specifies the path to the child element whose value needs to be returned.
|
||||||
|
// If it is not specified then a value from the first argument (view) is returned.
|
||||||
|
func ScrollIntoViewIfNeeded(view View, subviewID ...string) {
|
||||||
|
if view = getSubview(view, subviewID); view != nil {
|
||||||
|
view.Session().callFunc("scrollIntoViewIfNeeded", view.htmlID())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue