tree_panning_js

NAML documentation   Watch a video
   Usages of this macro
... in topic.naml
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
<macro name="tree_panning_js">
    <script type="text/javascript">
        $(document).ready(function() {
            (function() {
                var down = null;
                var initialLeft = null;
                var $area = $('#threaded-contents');
                function startDrag(e) {
                    if (e.target == this) {
                        down = e.pageX;
                        initialLeft = parseInt($area.css('margin-left'));
                        return false;
                    }
                };
                function drag(e) {
                    if (down) {
                        var m = initialLeft + (e.pageX - down);
                        $area.css('margin-left',m > 0? '0' : m+'px');
                    }
                };
                function stopDrag(e){
                    down = null;
                    initialLeft = null;
                };
                $('div.connect-inner,#topic-contents')
                    .mousedown(startDrag)
                    .mousemove(drag)
                    .mouseup(stopDrag);
                $(document).mouseup(stopDrag);
            })();
        });
    </script>
</macro>