     func scrollViewDidScroll(scrollView: UIScrollView) {
         if (scrollView == activeScrollView) {
             if (scrollView == tabScrollView) {
-                contentScrollView.contentOffset.x = (tabScrollView.contentOffset.x + tabScrollView.contentInset.left) * (contentScrollView.contentSize.width / tabScrollView.contentSize.width)
+                contentScrollView.contentOffset.x = (tabScrollView.contentOffset.x + tabScrollView.contentInset.left) * (contentScrollView.contentSize.width / tabScrollView.contentSize.width) - contentScrollView.contentInset.left
             }
             
             if (scrollView == contentScrollView) {
-                tabScrollView.contentOffset.x = contentScrollView.contentOffset.x * (tabScrollView.contentSize.width / contentScrollView.contentSize.width) - tabScrollView.contentInset.left
+                tabScrollView.contentOffset.x = (contentScrollView.contentOffset.x + contentScrollView.contentInset.left) * (tabScrollView.contentSize.width / contentScrollView.contentSize.width) - tabScrollView.contentInset.left
             }
             resetTabs()
         }

                }
                // set default position of tabs and contents
                tabScrollView.contentOffset = CGPoint(x: tabOffsetX + tabScrollView.contentInset.left * -1, y: tabScrollView.contentOffset.y)
                contentScrollView.contentOffset = CGPoint(x: contentOffsetX, y: contentScrollView.contentOffset.y)
                
                resetTabs()
            }

//   2. Infinite Scrolling
//   3. Performace improvement
//   4. Adjust the scrolling offset if tabs have diffent widths
//   5. Add paging support if the size of page.contentViews are smaller than tabScrollView size

import UIKit

