0.3.0 • Published 2 years ago

capacitor-native-pull-to-refresh v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

capacitor-native-pull-to-refresh

Native pull to refresh plugin for capacitor

Install

npm install capacitor-native-pull-to-refresh
npx cap sync
import { PullToRefresh } from "capacitor-native-pull-to-refresh";

This plugin Is a WIP.

API

enable()

enable() => Promise<PullToRefreshResponse>

Enables the pull-to-refresh functionality.

Returns: Promise<PullToRefreshResponse>


disable()

disable() => Promise<PullToRefreshResponse>

Disables the pull-to-refresh functionality.

Returns: Promise<PullToRefreshResponse>


endRefreshing()

endRefreshing() => Promise<PullToRefreshStateResponse>

Ends the refreshing state initiated by pull-to-refresh.

Returns: Promise<PullToRefreshStateResponse>


setScrollPosition(...)

setScrollPosition(options: SetScrollPositionOptions) => void

Sets the scroll position of the webView.scrollView.

Optional to use, default behavior of UIRefreshControl() only works with the main scrollview, so a workaround is needed for additional scroll containers e.g. modals.

This function is specific to iOS. platform: iOS

ParamTypeDescription
optionsSetScrollPositionOptionsConfiguration options for setting the scroll position.

manuallyTriggerRefreshingState(...)

manuallyTriggerRefreshingState(options: ManuallyTriggerRefreshingStateOptions) => void

Manually triggers the refreshing state.

This method can be used in conjunction with @setScrollPosition to manage the refreshing state based on custom logic.

Example:

const threshold = -100;

scrollContainer.addEventListener("scroll", async function () { if (scrollContainer.scrollTop < 0) { PullToRefresh.setScrollPosition({ scroll_position: scrollContainer.scrollTop, threshold: threshold }); } });

scrollContainer.addEventListener("touchend", async function () { if (scrollContainer.scrollTop <= threshold) { PullToRefresh.manuallyTriggerRefreshingState({ offset: -30 }); } });

PullToRefresh.addListener("state", function ({ refreshing }) { if (refreshing) { setTimeout(() => { PullToRefresh.endRefreshing(); }, 3000); } });

This function is specific to iOS. platform: iOS

ParamTypeDescription
optionsManuallyTriggerRefreshingStateOptionsConfiguration options when manually triggering refreshing state.

addListener('state', ...)

addListener(eventName: 'state', listenerFunc: (data: PullToRefreshStateResponse) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Adds a listener for the "state" event which is triggered when the pull-to-refresh state changes.

ParamTypeDescription
eventName'state'The name of the event to listen for.
listenerFunc(data: PullToRefreshStateResponse) => voidThe function to be executed when the event is triggered.

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


removeAllListeners()

removeAllListeners() => Promise<void>

Interfaces

PullToRefreshResponse

PropType
enabledboolean

PullToRefreshStateResponse

PropType
refreshingboolean

SetScrollPositionOptions

PropType
scroll_positionnumber
thresholdnumber

ManuallyTriggerRefreshingStateOptions

PropType
offsetnumber

PluginListenerHandle

PropType
remove() => Promise<void>
0.3.0

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago