0

I'm having difficulties making angular-pintura work. Image Source is loaded but the width, height of the canvas is still 0. I need to adjust the display (rotate to portrait/landscape, adjust the width of the browser) in order for it to load the proper width and height of the image.

Here is the github source for angular-pintura.

And here is my code -

AngularJs (Passing of Source Image)

vm.modalInstance = $modal.open({
    templateUrl: '/app/directives/app-viewer/image-viewer/image-viewer.html',
    controller: 'ImageViewerController',
    controllerAs: 'vm',
    resolve: {
        params: function () {
            return {
                src: '/assets/img/bg-1.jpg'
            }
        }
    }
});

Controller ImageViewer

function imageViewerController($modalInstance, params, $scope) {
    var vm = this;

    vm.image = {
        src: params.src,
        position: {
            x: -137.5,
            y: -68
        },
        scaling: 2,
        maxScaling: 5,
        scaleStep: 0.11,
        mwScaleStep: 0.09,
        moveStep: 99,
        fitOnload: true,
        progress: 0
    }
}

HTML

<ng-pintura ngp-src="vm.image.src" ngp-scaling="vm.image.scaling" ngp-position="vm.image.position" 
    ngp-max-scaling="vm.image.maxScaling" ngp-scale-step="vm.image.scaleStep" ngp-move-step="vm.image.moveStep" ngp-mw-scale-step="vm.image.mwScaleStep" ngp-fit-onload="vm.image.fitOnload" ngp-progress="vm.image.progress">
    <div id="zoomslider">
        <input ng-model="slider.value" ng-change="sliderChange()" orient="vertical" type="range" min="0" max="100" step="1" ng-disabled="scalingDisabled">
    </div>
    <button id="zoomin" ng-click="zoomIn()" ng-disabled="scalingDisabled" class="btn btn-default hidden-xs"><span class="glyphicon glyphicon-plus"></span></button>
    <button id="zoomout" ng-click="zoomOut()" ng-disabled="scalingDisabled" class="btn btn-default hidden-xs"><span class="glyphicon glyphicon-minus"></span></button>
    <button id="moveup" ng-click="moveUp()" class="btn btn-default hidden-xs"><span class="glyphicon glyphicon-chevron-up"></span></button>
    <button id="movedown" ng-click="moveDown()" class="btn btn-default hidden-xs"><span class="glyphicon glyphicon-chevron-down"></span></button>
    <button id="moveleft" ng-click="moveLeft()" class="btn btn-default hidden-xs"><span class="glyphicon glyphicon-chevron-left"></span></button>
    <button id="moveright" ng-click="moveRight()" class="btn btn-default hidden-xs"><span class="glyphicon glyphicon-chevron-right"></span></button>
    <button id="movecenter" ng-click="fitInView()" class="btn btn-default"><span class="glyphicon glyphicon-screenshot"></span></button>
</ng-pintura>
Gabriel Llorico
  • 1,783
  • 1
  • 13
  • 23

1 Answers1

1

It's obligatory to set width and height explicitly in your stylesheets.

ng-pintura {
    position: relative;
    display: block;
    width: 100%;
    height: 600px;
    background: black;
}

I took the css code from angular-pinturas github page.

kruschid
  • 759
  • 4
  • 10