Giter VIP home page Giter VIP logo

angular-photoswipe's Introduction

COLLABORATORS WANTED

Unfortunately I cannot actively contribute and maintain this module anymore.

There seems to be enough interest to keep it going, so if anyone who's using it would like to become a collaborator please inbox me

Angular PhotoSwipe

AngularJS directive for PhotoSwipe.

Copyright © 2016, Massimiliano Sartoretto

Find me on: alt text alt text alt text

Installation

You can choose your preferred method of installation:

  • Through bower: bower install ng-photoswipe --save
  • Through npm: npm install ng-photoswipe --save
  • Download from github: angular-photoswipe.min.js

Usage

Inject ngPhotoswipe module in your application with:

angular
  .module('myApp', ['ngPhotoswipe'])

and use the directive as below:

<div ng-photoswipe
     slides="slides"
     slide-selector=".my-awesome-thumbnail"
     open="isOpen"
     on-close="onGalleryClose()"
     template="'./myGallery.template.html'"
     options="opts"></div>

where slides is an object defining the images, and the slideSelector is a valid selector to query the gallery images.

The open attribute is a scope boolean that start the gallery when truthy.

The on-close callback will be called after the gallery closes, not surprising.

You can also provide your own template that will override the default one.

(For further infos follow the Official docs)

Changelog

v0.1.1 (May 12, 2016)

  • Fix overridden opts

v0.1.0 (May 05, 2016)

  • Animation support for multiple galleries
  • Fix start animation

v0.0.9 (Feb 15, 2016)

  • Add ngTemplates grunt task
  • Fix npm package version

v0.0.8 (Dec 28, 2015)

  • Add custom event to manually start Photoswipe
  • Better demo

v0.0.7 (Dec 18, 2015)

  • Better grunt build
  • Add template attribute to override the default html template

v0.0.6 (Dec 11, 2015)

  • Fix DI bug due to undefined controller
  • Improve jshint rules

v0.0.5 (Dec 08, 2015)

  • Update bower configuration

v0.0.4 (Aug 29, 2015)

  • Move link definition inside directive block

v0.0.3 (Aug 27, 2015)

  • Update demoApp
  • Better code style

v0.0.2 (Aug 27, 2015)

  • Add JP's jshint
  • External template compilation

v0.0.1 (Aug 26, 2015)

  • Add directive template
  • Add ngPhotoswipeProvider

angular-photoswipe's People

Contributors

dannystaten avatar g41n avatar m00s avatar yanbab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

angular-photoswipe's Issues

Not able to open photoswipe using the example

I have looked at the demo and tried to reproduce it inside in one project. I am using the demo code for it first but somehow the gallery does not open. From my point of view it has got something to do with the event but I am not sure what exactly is wrong.
Here the part of the HTML code I am using:

<div ng-controller="demoCtrl as vm">
    <button ng-click="vm.showGallery()"> Show Gallery (external btn) </button>
        <ul class="slide-list">
                 <li ng-repeat="s in vm.slides track by $index" ng-click="vm.showGallery($index)">
                        <img ng-src="{{ s.src }}" alt="slide number {{ $index }}" />
                 </li>
         </ul>
     <div ng-photoswipe slides="vm.slides" start-on="{{ vm.startEvent }}" options="vm.opts"></div>
</div>

And this is my javascript code:

test.controller('demoCtrl', function($scope) {
    var vm = this;

  vm.title = 'ngPhotoswipe';
  vm.startEvent = 'START_GALLERY';

  vm.opts = {
    index: 0
  };

  vm.slides = [{
      src: 'http://lorempixel.com/500/500/nature',
      w: 500, h: 500
    }, {
      src: 'http://lorempixel.com/500/500/abstract',
      w: 500, h: 500
    }, {
      src: 'http://lorempixel.com/500/500/sports',
      w: 500, h: 500
    }, {
      src: 'http://lorempixel.com/500/500/city',
      w: 500, h: 500
    }, {
      src: 'http://lorempixel.com/500/500/food',
      w: 500, h: 500
    }, {
      src: 'http://lorempixel.com/500/500/animals',
      w: 500, h: 500
    }, {
      src: 'http://lorempixel.com/500/500/business',
      w: 500, h: 500
    }, {
      src: 'http://lorempixel.com/500/500/fashion',
      w: 500, h: 500
    }];

  vm.showGallery = function (i) {
    vm.opts.index = i || vm.opts.index;
    $scope.$broadcast(vm.startEvent);
  };
});

This is my top line where I initialize the angular app which I have got included in the body tag:

var test = angular.module('test', ['ngRoute', 'ngCookies', 'ngDialog', 'pascalprecht.translate', 'ngFileUpload', 'satellizer', 'ngSanitize', 'ngTouch', 'superswipe', 'cropme', 'google.places', 'moment-picker', 'infinite-scroll', 'cgNotify','ngPhotoswipe']).config(function($authProvider) {

When I click on an image or the button nothing happens. The function is run since I tried a console.log which gives me the correct value for i and for the event name. Also everything is working fine in the html code so that the scope variables are correctly used. I do not get any error in the console when clicking or loading the gallery. From my point of view something does not work with the event. The demoCtrl is inside another controller which is inside the main controller. I hope this is not the problem.

Routing to another page error

https://vimeo.com/264209784

this what happened to my angular photoswipe
when i route to another page after clicking the image and opening photoswipe
the page redirect me to home
but
https://vimeo.com/264213915
this video shows okay i used to click the another album after clicking the image then route to
another page and it works fine

i did not used all your codes
this is my html codes

        <div class="album-panel">
            <ul>
                <li ng-repeat="wed in Album" ng-click="AlbumClick(wed)">
                    <img image-exist ng-src="{{wed.WebPath}}" />
                    <div class="descp">
                        <p>{{wed.Title}}</p>
                        <p class="sub">{{wed.PhotoCount}} PHOTO(S)</p>
                    </div>
                </li>
            </ul>
        </div>
        <div class="photo-panel">
            <div id="photos">
                <div ng-repeat="s in Pictures.slides track by $index" ng-click="showGallery($index)">
                    <img ng-src="{{ s.src }}" image-exist alt="slide number {{ $index }}" />
                </div>
                <div photo-swipe slides="Pictures.slides" open="Pictures.open" slide-selector="#photos > div > img" options="Pictures.options"></div>
            </div>
        </div>
    </div>

then this is my directive

`var photoSwipe = function (c, h, temp) {
return {
restrict: 'AE',
replace: true,
scope: {
open: '=',
options: '=',
slides: '=',
slideSelector: '@',
template: '@'
},
link: function (scope, element, attrs) {
scope.template = scope.template || 'dialogs/PhotoSwipe.html';

            h.get(scope.template, { cache: temp }).then(function (r) {
                var template = angular.element(r.data);
                element.append(c(template)(scope));
            }) 
            var sGallery = (function () {
                var pswpElement = document.querySelectorAll('.pswp')[0];
                if (angular.isUndefined(scope.options.getThumbBoundsFn) &&
                    angular.isDefined(scope.slideSelector)) {
                    scope.options = angular.merge({}, {
                        getThumbBoundsFn: function (index) {
                            var tn = document.querySelectorAll(scope.slideSelector)[index];
                            var pageYscroll = window.pageYOffset || document.documentElement.scrollTop;
                            var r = tn.getBoundingClientRect();
                            return { x: r.left, y: r.top + pageYscroll, w: r.width };
                        }
                    }, scope.options)
                } 
                scope.gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default || false, scope.slides, scope.options);
                scope.gallery.init();
                scope.item = scope.gallery.currItem; 
                scope.gallery.listen('destroy', function () {
                    scope.open = false;  
                }); 
            }); 
            scope.$watch('open', function (nVal, oVal) {
                if (nVal != oVal) {
                    if (nVal != undefined) {
                        sGallery();
                    }
                } else if (!nVal && scope.gallery) {
                    scope.gallery.close();
                    scope.gallery = null;
                }
            }); 
        }
    };
} 
wDirectivesApp.directive('photoSwipe', ['$compile', '$http', '$templateCache', photoSwipe]);`

then this is my controller

$s.Pictures.options = { index: 0 }

    $s.AlbumClick = (function (ap) {    
        $s.Pictures.open = undefined; 
        $s.Pictures.slides =  Enumerable.From($s.Album).Where(function (x) { return x.ID == ap.ID }).Join($s.BKPic, function (x) { return x.ID }, function (a) { return a.ID_Album }, function (x, a) { return { src: a.WebPath, h: a.Height, w: a.Width } }).OrderBy(function (x) { return x.SeqNo }).ToArray() ;
    }) ;
    $s.showGallery = (function (i) { 
        if (angular.isDefined(i)) {
            $s.Pictures.options.index = i;
        }
        $s.Pictures.open = true;
    });`

i just paste all the codes that need only to use photoswipe

sorry i modify your codes but this codes works fine, but when i used your code im having a problem in
closing and opening the photoswip so i modify some of your codes.

default-skin.png does not found in dist version

We are using Yeoman scaffolding in our project. When we run grunt serve:dist, the default-skin.png file doesn't found in dist folder - photoswipe plugin look for styles/default-skin.png.

Doesnt work on minified version using angular-yeoman

The directive template is inserted on the DOM but when I click on an image the photoswipe gallery doesn't show.

In the minified version of my yeoman proyect I can see the Photoswipe and ng-photoswipe code.

Cant Load Image-Base 64 src

saccgqk
#I'm using ng-Photoswipe, with images from my database.

But when I click on the image to view it, I get "Unable to load Image -(Request-URI Too Long)". Does the src attribute have to be a folder/ https link to the image?

Add carousel slider on gallery

Hi guys, I want to ask that is there any way to integrate carousel slider on any other slider to angular photoswipe images.

Thanks

ReferenceError: PhotoSwipe is not defined

Hi, I have installed angular-photoswipe via npm but when I try to use it I have this error:

angular_angular.js:13439 ReferenceError: PhotoSwipe is not defined
    at g (angular-photoswipe.min.js:7)
    at angular-photoswipe.min.js:7
    at Scope.$digest (angular_angular.js:16884)
    at Scope.$apply (angular_angular.js:17148)
    at HTMLAnchorElement.<anonymous> (angular_angular.js:24828)
    at HTMLAnchorElement.jQuery.event.dispatch (jquery.js:4723)
    at HTMLAnchorElement.elemData.handle (jquery.js:4391)

I use angular on meteor framework.

I have the same error if I try to include it directly without using npm.

Any hint would be appreciated, let me know if you need further details.

Best regards.

Does not work properly with index: 0

Thanks for this great module.

In the demo, if any other image has previously been selected & displayed, clicking the first thumbnail image (index 0) image will open the Photoswipe UI displaying the previous image. Clicking on the second image (index 1) works correctly, as do all subsequent images. Only images with index 0 do not work properly.

Problem with template URL

While trying to use this module, I encountered an error with the default URL for the template defined in the directive.

function linkFn(scope, iElement, iAttrs) {
        scope.template = scope.template || 'views/ng-photoswipe.html';

        scope.$on(scope.startOn, function () {
          scope.start();
        });

This caused my browser to look for the template at http://example.com/views/ng-photoswipe.html, rather than within the ng-photoswipe directory (in bower_components).

Animation support for multiple galleries

From #9 by @hirbod

While this is working fine when you only have one gallery, how to go on with multiple ones?

There is an official doc about that:
http://photoswipe.com/documentation/getting-started.html#dom-to-slide-objects

and a working example:
http://codepen.io/dimsemenov/pen/ZYbPJM

But I really don't have a clue right now, how to use this with this directive. Any guesses?

I think it can be a major improvements even though a not-so-common scenario.

I open this issue to think and discuss about it

Angular bindings in template: how to?

Hi.

I'd like to set some angular bindings in the template, like ng-class or ng-click, referring the current slide, something like ng-click="markAsSelected(currentSlide)", or ng-class="{ 'selected': currentSlide.selected }".

Is it possible? How?

Thanks!

No animations when opening file

I don't know if it is only me, but I don't see any animations, and it is a bit disturbing, sice that is one of main reasons, why I wanted PhotoSwipe. (in demo)

Photoswipe query string causes problems with UI Router

When I display an image with the Photoswipe UI, it appends a &gid=x&pid=x query string to the URL. This causes UI Router to see it as a different URL than the base URL of the page as defined in that URL's .state, causing it to immediately redirect to the URL defined in $urlRouterProvider.otherwise().

I can turn this off with Photoswipe's history option, but is there any way to keep the gid&pid history while using this with UI Router?

Demo not workin

I'm testing your demo and this does not work, what happens?

slideSelector

Add the possibility to add a variable to slideSelector

pswp crash

First image loads properly but after swiping to next image all the elements under element are destroyed.

bower.json invalid main

bower.json file has "main": "angular-aviary.min.js".
I'm guessing this should be angular-photoswipe.min.js for this to work.
At least changing that worked for me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.