GithubHelp home page GithubHelp logo

current index about ngx-ui-scroll HOT 6 CLOSED

cristigav avatar cristigav commented on August 14, 2024
current index

from ngx-ui-scroll.

Comments (6)

dhilt avatar dhilt commented on August 14, 2024 1

Let's try v0.0.6! Documentation is not updated, so I want to put some notes here:

  • use new Datasource(...) in your component to instantiate the datasource with the Adapter
  • use {{datasource.adapter.firstVisible.$index}} in your template to output first visible item's index where firstVisible is dynamically updated item object
  • use {{(datasource.adapter.firstVisible$ | async)?.$index}} in your template to output first visible item's index where firstVisible$ is BehaviourSubject of first visible item object
  • use this.datasource.adapter.firstVisible$.subscribe((value) => console.log(value.$index)); in your component's code to catch the exact moment when first visible item is changed
  • the subscription is smart enough, so you may subscribe even on your component's constructor before the uiScroll is initialized itself

The first visible item object has following properties

ItemAdapter {
  $index?: number;
  data?: any;
  element?: HTMLElement;
}

This type is not exported out of the UiScroll module for now.

from ngx-ui-scroll.

brunohbelo avatar brunohbelo commented on August 14, 2024 1

I have updated to version 0.0.6 and the current index works fine! thanks

from ngx-ui-scroll.

dhilt avatar dhilt commented on August 14, 2024

@cristigav I drafter a solution in first-visible branch. Could you try it before next release?

git clone https://github.com/dhilt/ngx-ui-scroll.git
cd ngx-ui-scroll
git checkout first-visible
npm install
npm start
http://localhost:4200/#/test

The Adapter got new property firstVisible that is an object of special type:

export interface ItemAdapter {
  $index?: number;
  data?: any;
  element?: HTMLElement;
}

So to have current top index you should do something like this:

{{datasource.adapter.firstVisible.$index}}

from ngx-ui-scroll.

cristigav avatar cristigav commented on August 14, 2024

Thanks, works ok 👍
I will use it with the next release.

from ngx-ui-scroll.

brunohbelo avatar brunohbelo commented on August 14, 2024

Hi folks, I also need that new feature about the first visible. There is a date for the next release?

from ngx-ui-scroll.

dhilt avatar dhilt commented on August 14, 2024

Okay, I'm going to postpone major release and promise to publish v0.0.6 in 1-2 days

from ngx-ui-scroll.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.