         self.automaticallyAdjustsScrollViewInsets = false
         headerView?.stories = stories
         headerView?.generateSnappers()
+        snapTimer = Timer.scheduledTimer(timeInterval: StoryConstants.snapTime, target: self, selector: #selector(IGStoryPreviewController.didMoveNextSnap), userInfo: nil, repeats: true)
     }
     
     //MARK: - Selectors

import UIKit

struct StoryConstants {
    static let snapTime:Double = 5.0
}

class IGStoryPreviewController: UIViewController {

    lazy var snapTimer = Timer.scheduledTimer(timeInterval: StoryConstants.snapTime, target: self, selector: #selector(IGStoryPreviewController.didMoveNextSnap), userInfo: nil, repeats: false)
    public var stories:[IGStory]?
    private var storyIndex:Int = 0
    var headerView:IGStoryPreviewHeaderView?
    
    @IBOutlet weak var storyPreview: UIView! {
        didSet {

        guard let stories = stories else {
            return
        }
        storyIndex = storyIndex+1
        if storyIndex == stories.count-1 {
            snapTimer?.invalidate()
            return
        }
        if storyIndex<stories.count{
            let indexPath = IndexPath.init(row: storyIndex, section: 0)
            collectionview.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true)
        }
    }
    //MARK: -
