MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / omtouchend

Function omtouchend

src/components/tabView.js:141–161  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

139 }
140
141 function omtouchend() {
142 document.removeEventListener("touchmove", omtouchmove);
143 document.removeEventListener("touchend", omtouchend);
144 document.removeEventListener("touchcancel", omtouchend);
145
146 // Only change tabs when a significant horizontal swipe is detected and not scrolling vertically
147 if (!isScrolling && Math.abs(moveX) > 100) {
148 const tabs = Array.from(el.get(".options").children).filter((child) =>
149 child.matches("span"),
150 );
151 const currentTab = el.get(".options>span.active");
152 const direction = moveX > 0 ? 1 : -1;
153 const currentTabIndex = tabs.indexOf(currentTab);
154 const nextTabIndex =
155 (currentTabIndex + direction + tabs.length) % tabs.length;
156 const nextTab = tabs[nextTabIndex];
157 nextTab.click();
158 if (currentTab) currentTab.classList.remove("active");
159 nextTab.classList.add("active");
160 }
161 }
162
163 function changeTab(e) {
164 const { target } = e;

Callers

nothing calls this directly

Calls 4

matchesMethod · 0.80
addMethod · 0.80
getMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected