@seed-design/react-drawer 1.0.8 → 1.0.9

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.
@@ -28,6 +28,11 @@ function isIPad() {
28
28
  function isIOS() {
29
29
  return isIPhone() || isIPad();
30
30
  }
31
+ function isAndroid() {
32
+ if (typeof window === "undefined" || typeof navigator === "undefined") return false;
33
+ return /Android/.test(navigator.userAgent);
34
+ }
35
+ // TODO: use userAgent instead?
31
36
  function testPlatform(re) {
32
37
  return typeof window !== "undefined" && window.navigator != null ? re.test(window.navigator.platform) : undefined;
33
38
  }
@@ -796,7 +801,7 @@ function useDrawer(props) {
796
801
  } else {
797
802
  drawerRef.current.style.height = `${Math.max(newDrawerHeight, visualViewportHeight - offsetFromTop)}px`;
798
803
  }
799
- } else if (!isMobileFirefox()) {
804
+ } else if (!isMobileFirefox() && !isAndroid()) {
800
805
  drawerRef.current.style.height = `${initialDrawerHeight.current}px`;
801
806
  }
802
807
  if (snapPoints && snapPoints.length > 0 && !keyboardIsOpen.current) {
@@ -51,6 +51,11 @@ function isIPad() {
51
51
  function isIOS() {
52
52
  return isIPhone() || isIPad();
53
53
  }
54
+ function isAndroid() {
55
+ if (typeof window === "undefined" || typeof navigator === "undefined") return false;
56
+ return /Android/.test(navigator.userAgent);
57
+ }
58
+ // TODO: use userAgent instead?
54
59
  function testPlatform(re) {
55
60
  return typeof window !== "undefined" && window.navigator != null ? re.test(window.navigator.platform) : undefined;
56
61
  }
@@ -819,7 +824,7 @@ function useDrawer(props) {
819
824
  } else {
820
825
  drawerRef.current.style.height = `${Math.max(newDrawerHeight, visualViewportHeight - offsetFromTop)}px`;
821
826
  }
822
- } else if (!isMobileFirefox()) {
827
+ } else if (!isMobileFirefox() && !isAndroid()) {
823
828
  drawerRef.current.style.height = `${initialDrawerHeight.current}px`;
824
829
  }
825
830
  if (snapPoints && snapPoints.length > 0 && !keyboardIsOpen.current) {
package/lib/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- var Drawer12s = require('./Drawer-12s-DXUv7jE4.cjs');
1
+ var Drawer12s = require('./Drawer-12s-B35ZJcKm.cjs');
2
2
 
3
3
  var Drawer_namespace = {
4
4
  __proto__: null,
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { D as DrawerBackdrop, a as DrawerCloseButton, b as DrawerContent, c as DrawerDescription, d as DrawerHandle, e as DrawerHeader, f as DrawerPositioner, g as DrawerRoot, h as DrawerTitle, i as DrawerTrigger } from './Drawer-12s-DnXlK1K0.js';
2
- export { u as useDrawer, j as useDrawerContext } from './Drawer-12s-DnXlK1K0.js';
1
+ import { D as DrawerBackdrop, a as DrawerCloseButton, b as DrawerContent, c as DrawerDescription, d as DrawerHandle, e as DrawerHeader, f as DrawerPositioner, g as DrawerRoot, h as DrawerTitle, i as DrawerTrigger } from './Drawer-12s-B-JAOvwq.js';
2
+ export { u as useDrawer, j as useDrawerContext } from './Drawer-12s-B-JAOvwq.js';
3
3
 
4
4
  var Drawer_namespace = {
5
5
  __proto__: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/react-drawer",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/daangn/seed-design.git",
package/src/browser.ts CHANGED
@@ -30,6 +30,13 @@ export function isIOS(): boolean | undefined {
30
30
  return isIPhone() || isIPad();
31
31
  }
32
32
 
33
+ export function isAndroid(): boolean | undefined {
34
+ if (typeof window === "undefined" || typeof navigator === "undefined") return false;
35
+
36
+ return /Android/.test(navigator.userAgent);
37
+ }
38
+
39
+ // TODO: use userAgent instead?
33
40
  export function testPlatform(re: RegExp): boolean | undefined {
34
41
  return typeof window !== "undefined" && window.navigator != null
35
42
  ? re.test(window.navigator.platform)
package/src/useDrawer.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { useControllableState } from "@seed-design/react-use-controllable-state";
2
2
  import type React from "react";
3
3
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
4
- import { isIOS, isMobileFirefox } from "./browser";
4
+ import { isAndroid, isIOS, isMobileFirefox } from "./browser";
5
5
  import {
6
6
  CLOSE_THRESHOLD,
7
7
  DRAG_CLASS,
@@ -606,7 +606,7 @@ export function useDrawer(props: UseDrawerProps) {
606
606
  } else {
607
607
  drawerRef.current.style.height = `${Math.max(newDrawerHeight, visualViewportHeight - offsetFromTop)}px`;
608
608
  }
609
- } else if (!isMobileFirefox()) {
609
+ } else if (!isMobileFirefox() && !isAndroid()) {
610
610
  drawerRef.current.style.height = `${initialDrawerHeight.current}px`;
611
611
  }
612
612