Git Product home page Git Product logo

angular-match-media's People

Contributors

bitflower avatar chrismcmacken avatar edmondchui avatar jacopotarantino avatar jhdrn avatar mollwe avatar sravenhorst avatar yizhao avatar zacronos 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  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-match-media's Issues

Uncaught TypeError: callback is not a function match-media.js:155

I installed this plugin in Angular 1.3 and I am using the .on method like this:

Main Controller:

vm.desktop = screenSize.on('md, lg');
vm.mobile = screenSize.on('xs, sm');

Ng-View:

<div ng-if="main.desktop">
  Show Desktop
</div>

<div ng-if="main.mobile">
  Show Mobile
</div>

Uploading media-query-plugin.png…

When the browser is resized, I keep getting this error in Google Chrome Console:

match-media.js:155 
Uncaught TypeError: callback is not a function
    at listenerFunc (match-media.js:155)

screenSize.is executing every time histary.back() is executed

Hi

I'm using this library because my client wants different views for desktop and mobile. I'm using library in routes and are making me a little bit crazy.

I have this:

angular
  .module('app', [
    'ngAnimate',
    'ngAria',
    'ngCookies',
    'ngMessages',
    'ngResource',
    'ngRoute',
    'ui.bootstrap',
    'ngSanitize',
    'ngTouch',
    'matchMedia',
    'ngMap'
  ])
  .config(function ($routeProvider, USER_ROLES) {
    $routeProvider
      .when('/', {
        redirectTo: '/entry',
        data: {
          authorizedRoles: [USER_ROLES.all]
        }
      })
      .when('/login', {
        templateUrl: 'views/login.html',
        controller: 'LoginCtrl',
        controllerAs: 'vm',
        data: {
          authorizedRoles: [USER_ROLES.all]
        }
      })
      .when('/entry', {
        templateUrl: 'views/entry_view.html',
        controller: 'EntryCtrl',
        controllerAs: 'entry',
        data: {
          authorizedRoles: [USER_ROLES.users, USER_ROLES.valid]
        },
        resolve: {
          mess: function($q, $location, $timeout, screenSize) {
            var deferred = $q.defer();

            $timeout(function() {
              if (screenSize.is('xs, sm')) {
                $location.path('/mobile/entry');
                deferred.reject();
              } else {
                deferred.resolve();
              }
            });

            return deferred.promise;
          }
        }
      })
      .when('/mobile/entry', {
        templateUrl: 'views/entry/mobile/lalala.html',
        controller: 'EntryMobileCtrl',
        controllerAs: 'entryMobile',
        data: {
          authorizedRoles: [USER_ROLES.teacher, USER_ROLES.valid]
        }
      })
      .when('/mobile/entry/members', {
        templateUrl: 'views/entry/mobile/members.html',
        controller: 'EntryMembersMobileCtrl',
        controllerAs: 'tmm',
        data: {
          authorizedRoles: [USER_ROLES.users]
        }
      })
/* and so on */
      .otherwise({
        redirectTo: '/',
        data: {
          authorizedRoles: [USER_ROLES.all]
        }
      });

  })
  .run(function($rootScope, $location, Authentication) {

    $rootScope.$on('$routeChangeStart', function(event, next, prev) {
      if ('$$route' in next && 'data' in next.$$route && 'authorizedRoles' in next.$$route.data) {
        var authorizedRoles = next.$$route.data.authorizedRoles;
        if (!Authentication.isAuthorized(authorizedRoles)) {
          $location.path('/login');
        }
      }

    });

    $rootScope.$on("$locationChangeSuccess",function(event,newUrl, oldUrl) {
      console.log("location: "+$location.path());
    });
  });

All works well but when i call $window.history.back() function from my headers screenSize.is is executed and user is moved to /mobile/entry

Anyone noticed about this?

Thanks

Add package.json

Please add a package.json file to the repo, so we can include this project with npm.

Thanks!

wrong number of parameters on onChange docs

in readme.md the onChange method should be

angular.module('myApp', ['matchMedia'])
.controller('mainController', ['screenSize', function (screenSize) {
  $scope.isMobile = screenSize.onChange($scope,'xs, sm', function(isMatch){
    $scope.isMobile = isMatch;
  });
}]);

Missing Cleanup Listener in when() API

In both the on() and onChange() APIs, the resize listener is cleaned up in scope.$destroy() event. However, the resize listener inside when() API is not cleaned up. Please add the appropriate code or I can submit a PR.

alias angular module name for consistency

Please alias 'angular-media-queries' as the angular module name, this is for naming consistency when using with a module loader.

like so:

angular.module('angular-media-queries', [matchMedia]);

Can't extend default rules

The var defaultRules can't be extended. When I create my own rules, I have to redeclare all the default rules too. This could cause problems if the default breakpoints change in a later version.

Example
screenSize.rules = {
lg: '(min-width: 1200px)', // default rule
md: '(min-width: 992px) and (max-width: 1199px)', // default rule
mobileLandscape: '(max-width: 768px) and (orientation: landscape)', // my custom rule
sm: '(min-width: 768px) and (max-width: 991px)', // default rule
xs: '(max-width: 767px)' // default rule
}

Please add minified build file to your repository.

Please add minified build file to your repository.

This help us to use minified files without the need to manually generate across development and production machines. Most libraries developers send the minified files together.

Thank you

Any Angular 2 support planned?

Just wanted to ask if angular 2 support was in the road map? If not did you have any idea of how to solve this problem in angular 2?

TypeScript typings

Hi,

I've created the necessary TypeScript typings for your module. The pull request on DefinitelyTyped can be found here. Hopefully it'll be merged soon.

Proper credit was given, but do check if there's anything you'd like to change.

Re-license to MIT

Having a CC license is rather atypical for software. Requiring attribution for a small module makes it difficult to use in some contexts.

Angular it self and many modules are licensed under the MIT license. Please consider to re-license your module and also provided it under the MIT license!

Wanted: Maintainer

If anyone is interested in contributing heavily to the development of this plugin or would like to give back to the community in a meaningful way, I would love help maintaining this plugin. Comment here or send me an email if interested.

.is() question

$scope.mobile = screenSize.is('xs');
$scope.desktop = screenSize.is('xm, md, lg');

These two variables are not changing if I'm resizing the browser screen on the fly.

onChange event missing

Hello,

nice and clean utility. Very handy!

The only thing it misses is a onChange event that would trigger when you actually change t-shirt view port and not on every resize...

so like
screenSize.onChange(new, function(....)

but would also help to have an old value, so from->to

screenSize.rules customization on config() step

It would be great if 'screenSize' service would be implemented as provider with methods for customization 'rules' object, thus it would be very convenient to define all custom rules on the app configuration step

Possible PR?

Hi, I was planning on making some improvements and submitting a PR, but once I started looking into the performance, and started thinking of new features I wanted, I ended up rewriting the entire code.

Subsequently I have no idea if I changed too much to make a PR, so I uploaded it to its own repository instead for now. I have zero experience publishing on Github so I'm not sure what the best way forward from here is? Should I still submit a PR?

If you want to check out what I've done it's at https://github.com/bensurman/angular-screenmatch

Watch off

Since screenSize.on is probably a watch, is there also a screenSize.off?

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.