Skip to content

Instantly share code, notes, and snippets.

@strarsis
Last active February 20, 2022 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strarsis/f2d300714cb27de420241aea06826dd1 to your computer and use it in GitHub Desktop.
Save strarsis/f2d300714cb27de420241aea06826dd1 to your computer and use it in GitHub Desktop.
`<IonItemSliding>` `onIonDrag` event handler `this` example
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;
<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