JSFiddle - React, Tailwind, and code Playground

by ced1870

HTML

<div id="css3controlgeneralcont">
                                                        <div id="slidetest" class="slideLeftButton">Click to slide left</div>
                                                        <div id="slidetest" class="slideRightButton">Click to slide right</div>
                                                        <div class="stylescontrolcontinner" id="scrolltest">
                                                            <div class="stylescontrolcontinnerfloat">
                                                                <div>
                                                                    <p title="<?php echo JText::_('CK_CSS_ELEMENT_MARGIN_INFO'); ?>" class="thisisatooltip">
                                                        <?php echo JText::_('CK_CSS_ELEMENT_MARGIN'); ?>
                                                    </p>
                                                    <div style="position:relative;height:100px;margin-top: 0px;">
                                                        <input class="inputbox cssapply" type="text" name="cssmarginleft" id="cssmarginleft" size="2" value="" style="position:absolute;left:0;top:15px;" />
                                                        <input class="inputbox cssapply" type="text" name="cssmargintop" id="cssmargintop" size="2" value=""  style="position:absolute;top:0;left:60px;" />
                                                        <input class="inputbox cssapply" type="text" name="cssmarginbottom" id="cssmarginbottom" size="2" value=""  style="position:absolute;top:40px;left:60px;" />
                                                        <input class="inputbox cssapply" type="text" name="cssmarginright" id="cssmarginright" size="2" value="" style="position:absolute;left: 120px;top:15px" />
                                                    </div>

                                                                                        <!--<input...

CSS

#css3controlgeneralcont {
    height: 330px;
    width: 770px;
    overflow: hidden;
    float: left;
    margin : 10px;

    position: absolute;
    border: 1px solid #fff;
    -moz-box-shadow: 0 0 5px #888;
    -webkit-box-shadow: 0 0 5px#888;
    box-shadow: 0 0 5px #888;
}

.stylescontrolcontinner {
    height: 330px;
}

.stylescontrolcontinnerfloat {
    float: left;
    width: 250px;
    height: 330px;
}

JavaScript

var stylesSliderCK = new Class({
    options: {
        innerClass: 'stylescontrolcontinner',
        innerBlocksClass: 'stylescontrolcontinnerfloat',
        leftButtonClass: 'slideLeftButton',
        rightButtonClass: 'slideRightButton'
    },

    initialize: function(el, options) {
        var el = document.id(el); if (!el) return;
        this.setOptions(options);
        this.leftButton = el.getParent().getElement('.'+this.options.leftButtonClass); if (!this.leftButton) return;
        this.rightButton = el.getParent().getElement('.'+this.options.rightButtonClass); if (!this.rightButton) return;
        this.innerBlocks = el.getElements('.'+this.options.innerBlocksClass); if (!this.innerBlocks) return;
        
        el.setProperty('width',250*this.innerBlocks.length);

        this.rightButton.addEvent('click', function(event) {
            event = new Event(event).stop();
            if (-el.getProperty('width') < el.getProperty('margin-left')-750) {
                el.tween('margin-left', el.getProperty('margin-left')-250);
                el.setProperty('margin-left',el.getProperty('margin-left')-250);
            }
        });
        
        this.leftButton.addEvent('click', function(event) {
            event = new Event(event).stop();
            if (el.getProperty('margin-left') < 0) {
                el.tween('margin-left', parseInt(el.getProperty('margin-left'))+250);
                el.setProperty('margin-left',parseInt(el.getProperty('margin-left'))+250);
            }
        });
    }
});
stylesSliderCK.implement(new Options);




new stylesSliderCK('scrolltest');