Comments (12)
Fixed in 1.8.1
thanks to @n0099. Closed.
from react-indiana-drag-scroll.
@n0099, why do you need smooth scroll behavior? What do you want to get?
from react-indiana-drag-scroll.
I have many anchor link targeting elements in ScrollContainer, and I don't wanna call scrollIntoView({ behavior: 'smooth' }) manually in the link's onClick handler.
from react-indiana-drag-scroll.
The library changes scrollTop
and scrollLeft
under the hood. When scroll-behavior
is smooth
this changes become smooth, so it produces the described scroll lags.
I can use scrollTo
method, that give the possibility to redefine scroll behavior, but IE-11 doesn't support it.
Perhaps, I should use scrollTo
method when it's available and change scrollTop
and scrollLeft
otherwise (IE-11 doesn't support smooth scroll behavior, so it won't be problem), but it's need to be sure that there are no browsers that support either scrollTo
method or scroll-behavior
feature.
from react-indiana-drag-scroll.
react-indiana-drag-scroll/src/index.js
Lines 266 to 271 in 329221f
change to
if (container.scrollBy) {
const scrollBy = {
left: horizontal ? -(newClientX - this.clientX) : 0,
top: vertical ? -(newClientY - this.clientY) : 0
}
container.scrollBy({ ...scrollBy, behavior: 'auto' })
} else {
if (horizontal) {
container.scrollLeft -= newClientX - this.clientX
}
if (vertical) {
container.scrollTop -= newClientY - this.clientY
}
}
I've tested on chrome and firefox with this change, it's still doesn't work, in fact determining behavior: 'auto'
doesn't cancel the effect of scroll-behavior: smooth
, and it's an expected behavior standardized by CSSOM.
CSSOM draft says:
If the user agent honors the scroll-behavior property and one of the following are true:
behavior is "auto" and element is not null and its computed value of the scroll-behavior property is smooth
behavior is smooth
...then perform a smooth scroll of box to position. Otherwise, perform an instant scroll of box to position.
It's also been mentioned in stackoverflow and webkit developers
But the MDN doc doesn't mention this, it just says: auto: The scrolling happens in a single jump.
, it's only correct when there's no scroll-behavior: smooth
style applied on the scrolling elements. In wild, I've seen some websites use body { scroll-behavior: smooth; }
to make all scrolling executed by js is smooth.
According to the previous stackoverflow answer, the only available workaround for compatible elements with scroll-behavior: smooth
style is adding scroll-behavior: auto !important;
after
So I think there's a lack of 'instant' value of ScrollToOptions in CSSOM to allow using js to perform instant scroll without touching style temporarily.
from react-indiana-drag-scroll.
@n0099 , did you try to sent scroll-behavior
to instant
? The example. But I'm not sure about its browser support.
from react-indiana-drag-scroll.
@n0099 , did you try to sent
scroll-behavior
toinstant
? The example.
It only works with chrome and is undocumented see w3c/webdriver#1449, w3c/webdriver#1493
from react-indiana-drag-scroll.
@n0099, it's pretty sad.
By the way, I've seen your pull request, thanks. It should work, but I need to test it anyway.
from react-indiana-drag-scroll.
@n0099 , did you try to sent
scroll-behavior
toinstant
? The example.It only works with chrome and is undocumented see w3c/webdriver#1449, w3c/webdriver#1493
It might be chrome's backward compatible with the same value of old scroll-behavior: 'instant'
style, where did you find this value?
In https://bugzilla.mozilla.org/show_bug.cgi?id=1086948 and w3c/csswg-drafts#2146:
Currently under section "Changes From 17 December 2013" there is a note:
The instant value of scroll-behavior was renamed to auto.
At "13. CSS properties" under "Smooth Scrolling: The scroll-behavior Property" it specifies Value: auto | smooth further saying "auto The scrolling box is scrolled in an instant fashion.". instant has been removed from here.
from react-indiana-drag-scroll.
I've encountered its mention in the translated version of this page. I assume it may be rudiment indeed and the issue in your last message confirms it. But, alas, auto
is not the full replacement of instant
.
from react-indiana-drag-scroll.
I've encountered its mention in the translated version of this page. I assume it may be rudiment indeed. That issue in your last message confirms it, but, alas,
auto
is not the full replacement ofinstant
.
So seems mdn just deleted instant
in english main version.
Maybe it's firefox who firstly implmented instant
value, see this email list: https://lists.w3.org/Archives/Public/www-style/2013Mar/0315.html
So Gecko internally has:
enum ScrollMode { INSTANT, SMOOTH, NORMAL };
INSTANT is what scrollTo and scrollBy do. NORMAL is done as one scroll,
but possibly async. SMOOTH will do smooth scrolling if the user has
that enabled, and behave like NORMAL otherwise.
Then at 2013-12, the css scroll-behaviour: instant
rename to auto
in the CSSOM, chrome changed this a year later.
https://bugs.chromium.org/p/chromium/issues/detail?id=243871#c38
Rename 'instant' value of scroll-behavior CSS property to 'auto'
This changes the 'instant' value of scroll-behavior to 'auto',
matching a change made in the CSSOM View spec (and also
matching Firefox's implementation).
But chrome doesn't remove behavior: instant
of ScrollOptions which firefox does, they might think they're not the same and still useful in such circumstances like now.
There's an answer that used instant
value in chromium based edge: https://stackoverflow.com/questions/52276194/window-scrollto-with-options-not-working-on-microsoft-edge/52288796#52288796
from react-indiana-drag-scroll.
@n0099 , did you try to sent
scroll-behavior
toinstant
? The example.It only works with chrome and is undocumented see w3c/webdriver#1449, w3c/webdriver#1493
I've just tested it on firefox, it works like chrome, so gecko still has supported instant
value nowadays.
from react-indiana-drag-scroll.
Related Issues (20)
- [Request] Option to remove body class HOT 9
- No way to get scroll offsets HOT 3
- There is no response to the components in ScrollContainer. HOT 8
- Doesn't work with scroll snapping HOT 3
- Any plan of migrating to function components? HOT 4
- Any plan to support React 18? HOT 5
- Activate drag scroll with the mouse wheel? HOT 5
- Change input in container HOT 4
- Horizontal scroll not working with touchpad HOT 7
- 'ScrollContainer' cannot be used as a JSX component. HOT 6
- style prop isn't applied in v3 HOT 10
- Dragging problem on touch devices HOT 8
- Add horizontal scroll support using a scroll wheel HOT 2
- reset scroll bar position HOT 1
- scrollLeft not set when scrolling with mousewheel HOT 3
- Receiving [Violation] warning on every render of ScrollContainer
- Bad importation at https://norserium.github.io/react-indiana-drag-scroll/ HOT 1
- v3 feedback HOT 1
- Doesn't work with Next.js 13+ HOT 4
- Focus removed from input elements HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-indiana-drag-scroll.