Pārlūkot izejas kodu

Switch scroll reference

Use client instead of offset sizes to exclude scrollbar in calculating
scroll amounts.
master
TheoryOfNekomata pirms 2 gadiem
vecāks
revīzija
880adeb247
1 mainītis faili ar 8 papildinājumiem un 8 dzēšanām
  1. +8
    -8
      src/pages/index.tsx

+ 8
- 8
src/pages/index.tsx Parādīt failu

@@ -322,11 +322,11 @@ const IndexPage: NextPage = () => {


scrollRef.current = true; scrollRef.current = true;
const target = e.currentTarget const target = e.currentTarget
if (target.scrollHeight > target.offsetHeight) {
worldScrollRef.current.scrollTop = Math.floor(target.scrollTop / (target.scrollHeight - target.offsetHeight) * (worldScrollRef.current.scrollHeight - worldScrollRef.current.offsetHeight));
if (target.scrollHeight > target.clientHeight) {
worldScrollRef.current.scrollTop = Math.floor(target.scrollTop / (target.scrollHeight - target.clientHeight) * (worldScrollRef.current.scrollHeight - worldScrollRef.current.clientHeight));
} }
if (target.scrollWidth > target.offsetWidth) {
worldScrollRef.current.scrollLeft = Math.floor(target.scrollLeft / (target.scrollWidth - target.offsetWidth) * (worldScrollRef.current.scrollWidth - worldScrollRef.current.offsetWidth));
if (target.scrollWidth > target.clientWidth) {
worldScrollRef.current.scrollLeft = Math.floor(target.scrollLeft / (target.scrollWidth - target.clientWidth) * (worldScrollRef.current.scrollWidth - worldScrollRef.current.clientWidth));
} }
} }


@@ -342,11 +342,11 @@ const IndexPage: NextPage = () => {


scrollRef.current = true; scrollRef.current = true;
const target = e.currentTarget const target = e.currentTarget
if (target.scrollHeight > target.offsetHeight) {
baseMapScrollRef.current.scrollTop = Math.floor(target.scrollTop / (target.scrollHeight - target.offsetHeight) * (baseMapScrollRef.current.scrollHeight - baseMapScrollRef.current.offsetHeight));
if (target.scrollHeight > target.clientHeight) {
baseMapScrollRef.current.scrollTop = Math.floor(target.scrollTop / (target.scrollHeight - target.clientHeight) * (baseMapScrollRef.current.scrollHeight - baseMapScrollRef.current.clientHeight));
} }
if (target.scrollWidth > target.offsetWidth) {
baseMapScrollRef.current.scrollLeft = Math.floor(target.scrollLeft / (target.scrollWidth - target.offsetWidth) * (baseMapScrollRef.current.scrollWidth - baseMapScrollRef.current.offsetWidth));
if (target.scrollWidth > target.clientWidth) {
baseMapScrollRef.current.scrollLeft = Math.floor(target.scrollLeft / (target.scrollWidth - target.clientWidth) * (baseMapScrollRef.current.scrollWidth - baseMapScrollRef.current.clientWidth));
} }
} }




Notiek ielāde…
Atcelt
Saglabāt