Pages

Wednesday, March 27, 2019

Scroll inside of the div upto fixed height scroll





/**
* App Features Scroll JS
*/

// $('.sec-inner--appFeatures .left-col').bind('mousewheel DOMMouseScroll', function (event) {
//     event.preventDefault();
//     total = $(".sec-inner--appFeatures .left-col").find('.mediaObject').length;
//     h = $(".sec-inner--appFeatures .left-col").height();
//     scroll(event, h, total);
// });
<div class="left-col tabs">
                            <a class="tab mediaObject mediaObject--md mediaObject--purple">
                                <div class="mediaObject__body">
                                    <div class="mediaObject__body__copy">
                                        <h2 class="mediaObject__title">Chumash with Rashi</h2>
                                        <p class="mediaObject__para">The daily learning of Chumash with Rashi is one of
                                            the three daily
                                            regimens which make up the learning of Chitas.</p>
                                    </div>
                                    <div class="mediaObject__body__img">
                                        <img src="img/feldheim_blank_1.png" alt="">
                                    </div>
                                </div>
                            </a>
                            <!-- ./mediaObject -->
                            <a class="tab mediaObject mediaObject--md mediaObject--orange">
                                <div class="mediaObject__body">
                                    <div class="mediaObject__body__copy">
                                        <h2 class="mediaObject__title">Chumash with Rashi</h2>
                                        <p class="mediaObject__para">The daily learning of Chumash with Rashi is one of
                                            the three daily
                                            regimens which make up the learning of Chitas.</p>
                                    </div>
                                    <div class="mediaObject__body__img">
                                        <img src="img/feldheim_blank_1.png" alt="">
                                    </div>
                                </div>
                            </a>
                            <!-- ./mediaObject -->
                            <a class="tab mediaObject mediaObject--md mediaObject--seaBlue">
                                <div class="mediaObject__body">
                                    <div class="mediaObject__body__copy">
                                        <h2 class="mediaObject__title">Chumash with Rashi</h2>
                                        <p class="mediaObject__para">The daily learning of Chumash with Rashi is one of
                                            the three daily
                                            regimens which make up the learning of Chitas.</p>
                                    </div>
                                    <div class="mediaObject__body__img">
                                        <img src="img/Kehot.png" alt="">
                                    </div>
                                </div>
                            </a>
                            <!-- ./mediaObject -->
                            <a class="tab mediaObject mediaObject--md mediaObject--lightGreen">
                                <div class="mediaObject__body">
                                    <div class="mediaObject__body__copy">
                                        <h2 class="mediaObject__title">Chumash with Rashi</h2>
                                        <p class="mediaObject__para">The daily learning of Chumash with Rashi is one of
                                            the three daily
                                            regimens which make up the learning of Chitas.</p>
                                    </div>
                                    <div class="mediaObject__body__img">
                                        <img src="img/Kehot.png" alt="">
                                    </div>
                                </div>
                            </a>
                            <!-- ./mediaObject -->
                            <a class="tab mediaObject mediaObject--md mediaObject--darkGreen">
                                <div class="mediaObject__body">
                                    <div class="mediaObject__body__copy">
                                        <h2 class="mediaObject__title">Chumash with Rashi</h2>
                                        <p class="mediaObject__para">The daily learning of Chumash with Rashi is one of
                                            the three daily
                                            regimens which make up the learning of Chitas.</p>
                                    </div>
                                    <div class="mediaObject__body__img">
                                        <img src="img/Untitffled-3.png" alt="">
                                    </div>
                                </div>
                            </a>
                            <!-- ./mediaObject -->
                            <a class="tab mediaObject mediaObject--md mediaObject--seaGreen">
                                <div class="mediaObject__body">
                                    <div class="mediaObject__body__copy">
                                        <h2 class="mediaObject__title">Chumash with Rashi</h2>
                                        <p class="mediaObject__para">The daily learning of Chumash with Rashi is one of
                                            the three daily
                                            regimens which make up the learning of Chitas.</p>
                                    </div>
                                    <div class="mediaObject__body__img">
                                        <img src="img/Untitffled-3.png" alt="">
                                    </div>
                                </div>
                            </a>
                            <!-- ./mediaObject -->
                            <a class="tab mediaObject mediaObject--md mediaObject--yellow">
                                <div class="mediaObject__body">
                                    <div class="mediaObject__body__copy">
                                        <h2 class="mediaObject__title">Chumash with Rashi</h2>
                                        <p class="mediaObject__para">The daily learning of Chumash with Rashi is one of
                                            the three daily
                                            regimens which make up the learning of Chitas.</p>
                                    </div>
                                    <div class="mediaObject__body__img">
                                        <img src="img/artscrollbw1.png" alt="">
                                    </div>
                                </div>
                            </a>
                            <!-- ./mediaObject -->
                            <a class="tab mediaObject mediaObject--md mediaObject--royalBlue">
                                <div class="mediaObject__body">
                                    <div class="mediaObject__body__copy">
                                        <h2 class="mediaObject__title">Chumash with Rashi</h2>
                                        <p class="mediaObject__para">The daily learning of Chumash with Rashi is one of
                                            the three daily
                                            regimens which make up the learning of Chitas.</p>
                                    </div>
                                    <div class="mediaObject__body__img">
                                        <img src="img/artscrollbw1.png" alt="">
                                    </div>
                                </div>
                            </a>
                        </div>



// $('.sec-inner--appFeatures .left-col').on('scroll', function (event) {
//     $('.sec-inner--appFeatures .left-col').bind('mousewheel DOMMouseScroll', function (event) {
//         event.preventDefault();
//         total = $(".sec-inner--appFeatures .left-col").find('.mediaObject').length;
//         h = $(".sec-inner--appFeatures .left-col").height();
//         scroll(event, h, total);
//     });
// });

// var num = 0;
// var scrolling = false;

// function scroll(event, h, total) {
//     event.preventDefault();

//     // For 6 Items per block
//     count = Math.ceil(total / 6);

//     // For 4 Items per block
//     // count = Math.ceil(total / 4);

//     if (!scrolling) {
//         scrolling = true;

//         if (event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0) {
//             num--;
//             num = num < 1 ? 0 : num;
//             hight_offset = num < 1 ? 0 : h * num;
//         } else {
//             if (num < count - 1) { num++; } num = num >= count ? count : num;
//             hight_offset = num > count ? num * h : (h) * num;
//         }

//         // console.log("hight_offset: "+hight_offset +" height:"+ h +" count: "+count+" Total:"+total+" Num:"+num);

//         $('.sec-inner--appFeatures .left-col').animate({
//             scrollTop: (hight_offset)
//         }, 500, "linear", function () {
//             scrolling = false;

//         });

//         if (num == parseInt(count - 1)) {
//             $(".sec-inner--appFeatures .left-col").unbind("mousewheel");
//             $(".sec-inner--appFeatures .left-col").bind("mousewheel");

//         } else if (num == 0) {
//             $(".sec-inner--appFeatures .left-col").unbind("mousewheel");
//             $(".sec-inner--appFeatures .left-col").bind("mousewheel");

//         } else {
//             bindSection();

//         }
//     }
// }

// function bindSection() {
//     $('.sec-inner--appFeatures .left-col').bind('mousewheel DOMMouseScroll', function (event) {
//         event.preventDefault();
//         total = $(".sec-inner--appFeatures .left-col").find('.mediaObject').length;
//         h = $(".sec-inner--appFeatures .left-col").height();
//         scroll(event, h, total);
//     })
// };