Last active
February 20, 2022 22:58
-
-
Save strarsis/f2d300714cb27de420241aea06826dd1 to your computer and use it in GitHub Desktop.
`<IonItemSliding>` `onIonDrag` event handler `this` example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
IonItemSliding, | |
} from '@ionic/react'; | |
type IonItemSlidingBackProps = { | |
children?: React.ReactNode; | |
}; | |
const IonItemSlidingBack: React.FC<IonItemSlidingBackProps> = ({ children }) => { | |
return ( | |
<IonItemSliding onIonDrag={(e) => { | |
if (e.detail.ratio >= 1) { | |
console.log('threshold'); | |
return; | |
} | |
this.close(); // this is always `undefined`, not `<IonItemSliding>` as one would expect | |
}} | |
> | |
{children} | |
</IonItemSliding> | |
); | |
}; | |
export default IonItemSlidingBack; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IonItemSlidingBack> | |
<IonItemOptions> | |
<IonItemOption color="danger" onClick={() => alert('call delete method here')} expandable> | |
Delete | |
</IonItemOption> | |
</IonItemOptions> | |
<IonItem detail={false}> | |
<IonLabel className="ion-text-wrap">Test</IonLabel> | |
</IonItem> | |
</IonItemSlidingBack> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment