css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <body ng-app="angularResizable" ng-controller="TestController">
    <a class="toggle" ng-href="#" ng-click="flexbox = !flexbox">
        <span ng-class="{'active':flexbox}">Standard</span>/
        <span ng-class="{'active':!flexbox}">Flexbox</span>
    </a>        
    <div class="info1">
        <h4>angularResizableEnd exports:</h4>
        <h4><span class="subtle">ID:</span> {{ size.id }}</h4>
        Width: <input type="number" ng-model="dynamicSize.width" /><br><br>
        Height: <input type="number" ng-model="dynamicSize.height" />
    </div>
    <div class="info2">
        <h4>events:</h4>
        <ul>
            <li class="animate-repeat" ng-repeat="event in events track by $index">
                {{ event.name }}
            </li>
        </ul>
    </div>
    <div class="container1" ng-class="{'active':flexbox}">
        <div resizable
             id="standard-box"
             r-directions="['right', 'bottom', 'left', 'top']"
             r-centered-x="true"
             r-centered-y="true"
             r-width="300"
             r-height="dynamicSize.height">
            <div class="inner">
                <h1>{{ msg }}</h1>
                <p>Testing out events on <a href="https://github.com/Reklino/angular-resizable" target="_blank">angular-resizable</a>.
                <br><br>
                <a href="https://github.com/Reklino/angular-resizable" target="_blank"><i class="fa fa-github-alt fa-3x"></i></a>
            </div>
        </div>
    </div>
    <div class="container2" ng-class="{'active':!flexbox}">
        <div resizable
             id="flexbox-box"
             r-directions="['right', 'left']"
             r-centered-x="true"
             r-centered-y="true"
             r-width="300"
             r-height="dynamicSize.height"
             r-flex="true">
            <div class="inner">
                <h1>{{ msg }}</h1>
                <p>Testing out events on <a href="https://github.com/Reklino/angular-resizable" target="_blank">angular-resizable</a>.
                <br><br>
                <a href="https://github.com/Reklino/angular-resizable" target="_blank"><i class="fa fa-github-alt fa-3x"></i></a>
            </div>
        </div>        
    </div>
</body>
            
          
!
            
              @import "compass/css3";

$color1: #343e3d;
$color2: #607466;
$color3: #aedcc0;
$color4: #7bd389;
$color5: #38e4ae;

body {
    color: $color1;
    font-family: 'Varela Round', 'Helvetica', sans-serif;
    background: url(https://subtlepatterns.com/images/transp_bg.png);
    overflow: hidden;
}

// **********************************************************************
// layout styles
// **********************************************************************
$spacing: 14px;
a {
    color: darken($color5, 15);
    &:hover { color: $color1; }
}
.subtle { color: #ccc; }
.container1, .container2 {
    transition: all .3s ease-in-out;     
    width: 100%;
    height: 100%;
    position: absolute;
}
.container1 {
    left: -100%;
    &.active { left: 0; }
    .resizable {
        margin: auto;
        top: 0; left: 0; right: 0; bottom: 15%;
    }
}
.container2 {
    display: flex;
    align-items: center;
    justify-content: center;
    left: 100%;
    &.active { left: 0; }
    .resizable {
        position: relative;
        margin-top: -10%;
    }
}
.resizable {
    text-align: center;
    box-sizing: border-box;
    width: 300px;
    height: 250px;
    background-color: $color5;
    border-radius: 10px;
}
.inner {
    box-sizing: border-box;
    overflow: hidden;
    padding: 1em;
    height: 100%;
    width: 100%;
}
.toggle {
    position: absolute;
    z-index: 1;
    top: 1em;
    right: 1em;
    color: #aaa;
    text-decoration: none;
    &:hover { color: #aaa; }
    .active { color: darken($color5, 15); }
}
.info1 {
    position: absolute;
    z-index: 1;
    bottom: 0; left: 0;
    padding: 1em 2em;
}
.info2 {
    position: absolute;
    z-index: 1;
    bottom: 0; right: 0;
    padding: 1em 2em;
    ul {
        height: 100px;
        overflow-y: scroll;
        overflow-x: hidden;
    }
}


// **********************************************************************
// directive styles
// **********************************************************************
.resizable {
    position: absolute;
    &.no-transition {
        transition: none !important;
        background-color: $color4;
    }
}
.rg-right, .rg-left, .rg-top, .rg-bottom {
    display: block;
    width: $spacing; height: $spacing; line-height: $spacing;
    position: absolute;
    z-index: 1;
    @include user-select(none);
    background: transparent;
    span {
        position: absolute;
        box-sizing: border-box;
        display: block;
        border: 1px solid #ccc;    
    }
}
.rg-right, .rg-left {
    span {
        border-width: 0 1px;
        top: 50%; margin-top: -10px;
        margin: -10px 0 0 $spacing/4;
        height: 20px;
        width: $spacing/2;
    }
}
.rg-top, .rg-bottom {
    span {
        border-width: 1px 0;
        left: 50%;
        margin: $spacing/4 0 0 -10px;
        width: 20px;
        height: $spacing/2;
    }
}
.rg-top     {
    cursor: row-resize;
    width: 100%;
    top: 0;
    left: 0;
    margin-top: -$spacing;
}
.rg-right   {
    cursor: col-resize;
    height: 100%;
    right: 0;
    top: 0;
    margin-right: -$spacing;
}
.rg-bottom  {
    cursor: row-resize;
    width: 100%;
    bottom: 0;
    left: 0;
    margin-bottom: -$spacing;
}
.rg-left    {
    cursor: col-resize;
    height: 100%;
    left: 0;
    top: 0;
    margin-left: -$spacing;
}
            
          
!
            
              angular.module('angularResizable', [])
	.controller('TestController', function($scope) {
    
    	$scope.dynamicSize = {
            'width' : 350,
            'height' : 250
        }
    	
    	$scope.flexbox = true;
    	$scope.size = {};
        $scope.msg = 'Resize me.';
    
    	$scope.events = [];
    	$scope.$on("angular-resizable.resizeEnd", function (event, args) {
			$scope.msg = 'Resize me again.';
			$scope.events.unshift(event);
			$scope.size = args;
			if(args.width)
				$scope.dynamicSize.width = args.width;
			if(args.height)
				$scope.dynamicSize.height = args.height;
        });
    	$scope.$on("angular-resizable.resizeStart", function (event, args) {
			$scope.msg = 'Woooohoooo!';
			$scope.events.unshift(event);
        });
	})
    .directive('resizable', function() {
        return {
            restrict: 'AE',
            scope: {
                rDirections: "=",
                rCenteredX: "=",
                rCenteredY: "=",
                rWidth: "=",
                rHeight: "=",
                rFlex: "="
            },
            link: function(scope, element, attr) {
                
                // register watchers on width and height attributes if they are set
                scope.$watch('rWidth', function(value){
                    element[0].style.width = scope.rWidth + 'px';
                });
                scope.$watch('rHeight', function(value){
                    element[0].style.height = scope.rHeight + 'px';
                });

                element.addClass('resizable');

                var style = window.getComputedStyle(element[0], null),
                    w,
                    h,
                    dir = scope.rDirections,
                    vx = scope.rCenteredX ? 2 : 1, // if centered double velocity
                    vy = scope.rCenteredY ? 2 : 1, // if centered double velocity
                    start,
                    dragDir,
                    axis,
                    info = {};
				
				var updateInfo = function() {
					info.width = false; info.height = false;
                    if(axis == 'x')
                    	info.width = scope.rFlex ? parseInt(element[0].style.flexBasis) : parseInt(element[0].style.width);
                    else
                    	info.height = scope.rFlex ? parseInt(element[0].style.flexBasis) : parseInt(element[0].style.height);
                    info.id = element[0].id;
				}

                var dragging = function(e) {
                    var offset = axis == 'x' ? start - e.clientX : start - e.clientY;
                    switch(dragDir) {
                        case 'top':
                            if(scope.rFlex) { element[0].style.flexBasis = h + (offset * vy) + 'px'; }
                            else {            element[0].style.height = h + (offset * vy) + 'px'; }          
                            break;
                        case 'right':
                            if(scope.rFlex) { element[0].style.flexBasis = w - (offset * vx) + 'px'; }
                            else {            element[0].style.width = w - (offset * vx) + 'px'; }
                            break;
                        case 'bottom':
                            if(scope.rFlex) { element[0].style.flexBasis = h - (offset * vy) + 'px'; }
                            else {            element[0].style.height = h - (offset * vy) + 'px'; }
                            break;
                        case 'left':
                            if(scope.rFlex) { element[0].style.flexBasis = w + (offset * vx) + 'px'; }
                            else {            element[0].style.width = w + (offset * vx) + 'px'; }
                            break;
                    }
                };
                var dragEnd = function(e) {
                    updateInfo();
                    scope.$emit("angular-resizable.resizeEnd", info);
					scope.$apply();
                    document.removeEventListener('mouseup', dragEnd, false);
                    document.removeEventListener('mousemove', dragging, false);
                    element.removeClass('no-transition');
                }
                var dragStart = function(e, direction) {
                    dragDir = direction;
                    axis = dragDir == 'left' || dragDir == 'right' ? 'x' : 'y';
                    start = axis == 'x' ? e.clientX : e.clientY;
                    w = parseInt(style.getPropertyValue("width"));
                    h = parseInt(style.getPropertyValue("height"));
                    
                    //prevent transition while dragging
                    element.addClass('no-transition');

                    document.addEventListener('mouseup', dragEnd, false);
                    document.addEventListener('mousemove', dragging, false);
                    
                    // Disable highlighting while dragging
                    if(e.stopPropagation) e.stopPropagation();
                    if(e.preventDefault) e.preventDefault();
                    e.cancelBubble = true;
                    e.returnValue = false;
					
                    updateInfo();
                    scope.$emit("angular-resizable.resizeStart", info);
					scope.$apply();
                };

                for(var i=0;i<dir.length;i++) {
                    (function () {
                        var grabber = document.createElement('div'),
                            direction = dir[i];

                        // add class for styling purposes
                        grabber.setAttribute('class', 'rg-' + dir[i]);
                        grabber.innerHTML = '<span></span>';
                        element[0].appendChild(grabber);
                        grabber.ondragstart = function() { return false }
                        grabber.addEventListener('mousedown', function(e) {
                            dragStart(e, direction);
                        }, false);
                    }())
                }

            }
        }
    });
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console