npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nativescript-na-slider

v1.1.3

Published

A NativeScript slider plugin

Downloads

5

Readme

NativeScript NA Slider plugin

NOTE! Android is currently not supported.

A NativeScript slider. The successor of my previous, deprecated slideshow plugin, nativescript-na-slideshow.

Installation

$ tns plugin add nativescript-na-slider

Usage

Slides can be added statically inside the XML as below:

<Page xmlns:NASlider="nativescript-na-slider">
  
  <NASlider:NASlider id="slider">
    <NASlider:NASliderContainer>
      <NASlider:NASliderSlide>
        <Label text="Slide 1" />
      </NASlider:NASliderSlide>
      <NASlider:NASliderSlide>
        <Label text="Slide 2" />
      </NASlider:NASliderSlide>
      <NASlider:NASliderSlide>
        <Label text="Slide 3" />
      </NASlider:NASliderSlide>
    </NASlider:NASliderContainer>
  </NASlider:NASlider>
  
</Page>

Using <Repeater>

For a more dynamic slider, a <Repeater> can be used:

<Page xmlns:NASlider="nativescript-na-slider">
  
  <NASlider:NASlider items="{{ slides }}">
    <Repeater>
      <Repeater.itemsLayout>
        <NASlider:NASliderContainer />
      </Repeater.itemsLayout>
      <Repeater.itemTemplate>
        <NASlider:NASliderSlide>
          <Label text="{{ text }}" />
        </NASlider:NASliderSlide>
      </Repeater.itemTemplate>
    </Repeater>
  </NASlider:NASlider>
  
</Page>

This way, a slider can simply be set up with an ObservableArray. The <NASliderContainer> will act as the Repeater's itemsLayout, while a <NASliderSlide> becomes the wrapper itemTemplate of the Repeater.

Properties

<NASlider>

| Property | Type | Description | | :------------------------------ | :---------------------------------- | :--------------------------------------- | | bounce | Boolean (default: false) | Gets or sets scroll bouncing effect. | | currentSlide | View<NASliderSlide> (read-only) | Gets the current slide view. | | currentSlideIndex | Integer (read-only) | Gets the current slide index. | | forceFirstIndicatorVisibility | Boolean (default: false) | Gets or sets the visibility of the first indicator if there is only one slide available. | | showIndicators | Boolean (default: true) | Gets or sets the indicators' visibility. | | indicatorBorderColor | String (default: "#404040") | Gets or sets indicators' border color. | | indicatorBorderWidth | Float (default: 0) | Gets or sets indicators' border width. | | indicatorColor | String (default: "808080") | Gets or sets the indicator color for all slides. | | indicatorColorActive | String (default: null) | Gets or sets the indicator color for all slides when active (current visible slide). | | indicatorHorizontalAlignment | String (default: null) | Gets or sets indicators' horizontal alignment. Overrides indicatorPosition property. | | indicatorPosition | String (default: "bottom") | Gets or sets indicators' position. | | indicatorSize | Float (default: 8) | Gets or sets indicators' size. | | indicatorVerticalAlignment | String (default: null) | Gets or sets indicators' vertical alignment. Overrides indicatorPosition property. | | items | Array (default: undefined) | Gets or sets the items array for a <Repeater>. | | orientation | String (default: "horizontal") | Gets or sets the slider orientation. Can be either "horizontal" or "vertical". | | scrollPosition | Float (read-only) | Gets the current scroll position. | | slidesCount | Integer (read-only) | Gets the total amount of slides. |

<NASliderSlide>

| Property | Type | Description | | :--------------------- | :----------------------- | :--------------------------------------- | | indicatorColor | String (default: null) | Gets or sets the indicator color for specific slide. | | indicatorColorActive | String (default: null) | Gets or sets the indicator color for specific slide when active (current visible slide). |

Methods

getSlideAt

getSlideAt(index: integer): <NASliderSlide>

Returns the slide at specified index.

| Parameter | Type | Description | | :-------- | :------ | :--------------------------------------- | | index | Integer | The index position of the slide to return. |


insertSlide

insertSlide(view: <View>, props: object): Promise<NASliderSlide>

Insert new slide with optional properties. Returns a Promise with the new slide.

| Parameter | Type | Description | | :-------- | :------------------ | :--------------------------- | | view | <View> | The view to insert as slide. | | props | Object (optional) | Optional properties. |

props

| Property | Type | Description | | :--------------------- | :-------------------------------------- | :--------------------------------------- | | atIndex | Integer (default: this.slidesCount) | Sets the index position. If not specified, the slide will become last. | | indicatorColor | String (default: null) | Sets the indicator color for specific slide. | | indicatorColorActive | String (default: null) | Sets the indicator color for specific slide when active (current visible slide). |


removeSlide

removeSlide(slide: <NASliderSlide>): Promise

Remove the specified slide. Returns a Promise.

| Parameter | Type | Description | | :-------- | :---------------- | :------------------- | | slide | <NASliderSlide> | The slide to remove. |


removeSlideAt

removeSlideAt(index : integer): Promise

Remove slide at specified index. Returns a Promise.

| Parameter | Type | Description | | :-------- | :------ | :--------------------------------------- | | index | Integer | The index position of the slide to remove. |


removeSlides

removeSlides(): Promise

Removes all slides. Returns a Promise.

Will not work if <NASlider> instance is maintained by a Repeater.


scrollToSlideAt

scrollToSlideAt(index : integer, animated : boolean): void

Scrolls to slide at specified index. Animated or not.

| Parameter | Type | Description | | :--------- | :------------------------- | :----------------------------- | | index | Integer | The slide to remove. | | animated | Boolean (default: false) | Animates the scrolling effect. |

Events

The following events can be observed with on() and addEventListener():

slide

Fired when sliding.

Event data

| Property | Type | Description | | :--------------- | :----- | :--------------------------------------- | | eventName | String | Gets the name of the event. | | object | Object | Gets the <NASlider> instance. | | scrollPosition | Float | Gets the current scroll position. Will be either the horizontal or vertical position depending on orientation of the <NASlider> instance. |


slideChange

Fired when the <NASlider> instance has changed slide.

Event data

| Property | Type | Description | | :---------- | :---------------- | :------------------------------ | | eventName | String | Gets the name of the event. | | object | Object | Gets the <NASlider> instance. | | slide | <NASliderSlide> | Gets the current visible slide. |

Known issues

  • No Android compatibility, yet.

History

Version 1.1.3 (February 10, 2017)

  • Fixed crash when navigating within the frame's backstack.

Version 1.1.2 (February 8, 2017)

  • Stability improvements.
  • Slides should now dynamically adapt to slider's dimensions.

Version 1.1.0 (February 7, 2017)

  • removeAllSlides method has been renamed to removeSlides.
  • Fixed Repeater not working as expected. Check documentation for the new way to use <NASlider>.

Version 1.0.2 (February 6, 2017)

  • Documentation fixes.

Version 1.0.0 (February 6, 2017)

  • First release!

Credits

License

MIT - for {N} version 2.5.0+