lupine.components 1.1.33 → 1.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lupine.components",
3
- "version": "1.1.33",
3
+ "version": "1.1.35",
4
4
  "license": "MIT",
5
5
  "author": "uuware.com",
6
6
  "homepage": "https://github.com/uuware/lupine.js",
@@ -223,8 +223,10 @@ export const MobileSideMenu = (props: { children: VNode<any>; autoExtend?: boole
223
223
  overflowY: 'auto',
224
224
  transform: 'translateX(-100%)',
225
225
  boxShadow: 'var(--cover-box-shadow)',
226
- 'padding-top ': 'constant(safe-area-inset-top)',
227
- 'padding-top': 'env(safe-area-inset-top)',
226
+ '@supports (-webkit-touch-callout: none)': {
227
+ 'padding-top ': 'constant(safe-area-inset-top)',
228
+ 'padding-top': 'env(safe-area-inset-top)',
229
+ },
228
230
  },
229
231
  [MediaQueryRange.TabletAbove]: {
230
232
  '&.auto-extend .mobile-side-menu-mask': {
@@ -35,8 +35,10 @@ export const ResponsiveFrame = (props: ResponsiveFrameProps) => {
35
35
  borderLeft: props.maxWidth ? '1px solid var(--primary-border-color)' : 'none',
36
36
  margin: '0 auto',
37
37
  overflowX: 'hidden',
38
- 'padding-top ': 'constant(safe-area-inset-top)',
39
- 'padding-top': 'env(safe-area-inset-top)',
38
+ '@supports (-webkit-touch-callout: none)': {
39
+ 'padding-top ': 'constant(safe-area-inset-top)',
40
+ 'padding-top': 'env(safe-area-inset-top)',
41
+ },
40
42
  '.frame-top-menu': {
41
43
  display: 'flex',
42
44
  flexDirection: 'column',
@@ -72,8 +72,10 @@ export const SliderFrame = (props: SliderFrameProps) => {
72
72
  transition: 'transform 0.4s ease-in-out',
73
73
  backgroundColor: 'var(--primary-bg-color)',
74
74
  // trick: to put two padding-top properties
75
- 'padding-top ': 'constant(safe-area-inset-top)',
76
- 'padding-top': 'env(safe-area-inset-top)',
75
+ '@supports (-webkit-touch-callout: none)': {
76
+ 'padding-top ': 'constant(safe-area-inset-top)',
77
+ 'padding-top': 'env(safe-area-inset-top)',
78
+ },
77
79
  '&.show': {
78
80
  transform: props.direction === 'bottom' ? 'translateY(0)' : 'translateX(0)',
79
81
  },
@@ -16,9 +16,11 @@ export const TopFrame = async (placeholderClassname: string, vnode: VNode<any>)
16
16
  flexDirection: 'column',
17
17
  height: '100%',
18
18
  // trick: to put two padding-top properties
19
+ '@supports (-webkit-touch-callout: none)': {
19
20
  'padding-top ': 'constant(safe-area-inset-top)',
20
21
  'padding-top': 'env(safe-area-inset-top)',
21
22
  },
23
+ },
22
24
  };
23
25
 
24
26
  return (
@@ -25,8 +25,9 @@ export const createDragUtil = () => {
25
25
  let isDragging = false;
26
26
  let initialX = 0;
27
27
  let initialY = 0;
28
+ let initialDirection: 'none' | 'vertical' | 'horizontal' = 'none';
28
29
  let draggingDom: HTMLDivElement | null = null;
29
- let onMoveCallback: (clientX: number, clientY: number, movedX: number, movedY: number) => void = () => {};
30
+ let onMoveCallback: (clientX: number, clientY: number, movedX: number, movedY: number, initialDirection: 'none' | 'vertical' | 'horizontal') => void = () => {};
30
31
  let onMoveEndCallback: () => void = () => {};
31
32
  let onScaleCallback: (scale: number) => void = () => {};
32
33
 
@@ -43,9 +44,10 @@ export const createDragUtil = () => {
43
44
  isDragging = false;
44
45
  isZooming = false;
45
46
  draggingDom = null;
47
+ initialDirection = 'none';
46
48
  };
47
49
  return {
48
- setOnMoveCallback: (callback: (clientX: number, clientY: number, movedX: number, movedY: number) => void) => {
50
+ setOnMoveCallback: (callback: (clientX: number, clientY: number, movedX: number, movedY: number, initialDirection: 'none' | 'vertical' | 'horizontal') => void) => {
49
51
  onMoveCallback = callback;
50
52
  },
51
53
  setOnMoveEndCallback: (callback: () => void) => {
@@ -54,6 +56,7 @@ export const createDragUtil = () => {
54
56
  setOnScaleCallback: (callback: (scale: number) => void) => {
55
57
  onScaleCallback = callback;
56
58
  },
59
+ getDirection: () => initialDirection,
57
60
  getDistance,
58
61
  getDraggingDom: () => draggingDom,
59
62
  onMouseDown: (event: MouseEvent) => {
@@ -68,6 +71,7 @@ export const createDragUtil = () => {
68
71
  draggingDom = event.currentTarget as HTMLDivElement;
69
72
  initialX = event.clientX;
70
73
  initialY = event.clientY;
74
+ initialDirection = 'none';
71
75
  },
72
76
  onMouseMove: (event: MouseEvent) => {
73
77
  if (event.buttons === 0 && isDragging) {
@@ -76,9 +80,17 @@ export const createDragUtil = () => {
76
80
  if (event.buttons === 0 || !draggingDom) {
77
81
  isDragging = false;
78
82
  draggingDom = null;
83
+ initialDirection = 'none';
79
84
  return;
80
85
  }
81
- onMoveCallback(event.clientX, event.clientY, event.clientX - initialX, event.clientY - initialY);
86
+ const movedX = event.clientX - initialX;
87
+ const movedY = event.clientY - initialY;
88
+ if (initialDirection === 'none') {
89
+ if (Math.abs(movedX) > 5 || Math.abs(movedY) > 5) {
90
+ initialDirection = Math.abs(movedX) > Math.abs(movedY) ? 'horizontal' : 'vertical';
91
+ }
92
+ }
93
+ onMoveCallback(event.clientX, event.clientY, movedX, movedY, initialDirection);
82
94
  },
83
95
  onMouseUp: onMoveEnd,
84
96
 
@@ -89,6 +101,7 @@ export const createDragUtil = () => {
89
101
  draggingDom = event.currentTarget as HTMLDivElement;
90
102
  initialX = event.touches[0].clientX;
91
103
  initialY = event.touches[0].clientY;
104
+ initialDirection = 'none';
92
105
  } else if (event.touches.length === 2) {
93
106
  initialDistance = getDistance(event.touches[0], event.touches[1]);
94
107
  isDragging = false;
@@ -96,6 +109,7 @@ export const createDragUtil = () => {
96
109
  } else {
97
110
  isDragging = false;
98
111
  draggingDom = null;
112
+ initialDirection = 'none';
99
113
  }
100
114
  },
101
115
  onTouchMove: (event: TouchEvent) => {
@@ -117,13 +131,22 @@ export const createDragUtil = () => {
117
131
  if (event.touches.length === 0 || !draggingDom) {
118
132
  isDragging = false;
119
133
  draggingDom = null;
134
+ initialDirection = 'none';
120
135
  return;
121
136
  }
137
+ const movedX = event.touches[0].clientX - initialX;
138
+ const movedY = event.touches[0].clientY - initialY;
139
+ if (initialDirection === 'none') {
140
+ if (Math.abs(movedX) > 5 || Math.abs(movedY) > 5) {
141
+ initialDirection = Math.abs(movedX) > Math.abs(movedY) ? 'horizontal' : 'vertical';
142
+ }
143
+ }
122
144
  onMoveCallback(
123
145
  event.touches[0].clientX,
124
146
  event.touches[0].clientY,
125
- event.touches[0].clientX - initialX,
126
- event.touches[0].clientY - initialY
147
+ movedX,
148
+ movedY,
149
+ initialDirection
127
150
  );
128
151
  },
129
152
  onTouchEnd: onMoveEnd,