Skip to main content

Carousel

Carousel is a component which can scroll(re render) item

import { Carousel } from "@tlgr/carousel";
const carousel = new Carousel(options);

Events described at events page

extends​

constructor(bot, options)​

  • bot - <Object>. Telegraf instance.

  • options - <Object>. Carousel options.

    • type - <string>. can be the one of the next items: 'photo' | 'audio' | 'animation' | 'video' | 'document'
    • items - <object | string> - Carousel item. Usually it is a url to content. E.g. https://example.com/path/to/image
    • mode - <string>. Reply mode. new - sends new message. edit - edit first sended message. Default is edit
    • loop - <boolean>. Loop mode. Starts over again when end item is reach out. Default is false
    • startFrom - <number> - Index which carousel will start. Default is 0.
    • controls - <object>. Controls decoration object. Override prev and next button behavior.
      • prev - <object>. Previous button decoration.
        • symbol - <string>. Previous symbol. Default is <.
        • alert - <object>. Alert options.
          • text- <string>. Alert text.
          • mode - <string>. Alert mode. Possible values: text or modal. Default is text
          • show - <boolean>. Show modal or not. Default is false.
      • next - <object>. Next button decoration.
        • symbol - <string>. Previous symbol. Default is >.
        • alert - <object>. Alert options.
          • text- <string>. Alert text.
          • mode - <string>. Alert mode. Possible values: text or modal. Default is text
          • show - <boolean>. Show modal or not. Default is false.

methods​

send(context)​

added in 1.1.0

Sends carousel from bot to user

render()​

added in 1.1.0

Note: this method are come from inheritance. This method returns prev and next buttons. Use send method instead.

properties​

item​

Return current render item.

index​

return current render item index in array which starts from 0.

length​

Carousel items length.