├── LICENSE ├── README.md ├── angular-slimscroll.js ├── bower.json └── package.json /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Tony Wang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | angular-slimscroll 2 | ================== 3 | This is a small directive to allow the use of jquery slimScroll plugin (https://github.com/rochal/jQuery-slimScroll) in angular. 4 | Get more detailed information about slimScroll, please visit: http://rocha.la/jQuery-slimScroll 5 | 6 | Install 7 | ------------ 8 | This plugin can be installed via bower. If you already have the bower installed in your machine, you can install it by the following command, if you are not familiar with bower, please refer to http://bower.io/ to learn more about the bower itself. 9 | 10 | ```javascript 11 | bower install angular-slimscroll --save 12 | ``` 13 | 14 | Then add `ui.slimscroll` as a dependency for your app: 15 | ```javascript 16 | var app = angular.module('app', ['ui.slimscroll']); 17 | ``` 18 | 19 | Usage 20 | ------------ 21 | 22 | ```html 23 |
24 | Scroll Content 25 |
26 | ``` 27 | 28 | Options 29 | ------- 30 | * **noWatch** - Prevent directive from watching the option object 31 | * **width** - Width in pixels of the visible scroll area. Stretch-to-parent if not set. Default: none 32 | * **height** - Height in pixels of the visible scroll area. Also supports auto to set the height to same as parent container. Default: 250px 33 | * **size** - Width in pixels of the scrollbar. Default: 7px 34 | * **position** - left or right. Sets the position of the scrollbar. Default: right 35 | * **color** - Color in hex of the scrollbar. Default: #000000 36 | * **alwaysVisible** - Disables scrollbar hide. Default: false 37 | * **distance** - Distance in pixels from the edge of the parent element where scrollbar should appear. It is used together with position property. Default:1px 38 | * **start** - top or bottom or $(selector) - defines initial position of the scrollbar. When set to bottom it automatically scrolls to the bottom of the scrollable container. When HTML element is passed, slimScroll defaults to offsetTop of this element. Default: top. 39 | * **wheelStep** - Integer value for mouse wheel delta. Default: 20 40 | * **railVisible** - Enables scrollbar rail. Default: false 41 | * **railColor** - Sets scrollbar rail color, Default: #333333 42 | * **railOpacity** - Sets scrollbar rail opacity. Default: 0.2 43 | * **allowPageScroll** - Checks if mouse wheel should scroll page when bar reaches top or bottom of the container. When set to true is scrolls the page.Default: false 44 | * **scrollTo** - Jumps to the specified scroll value. Can be called on any element with slimScroll already enabled. Example: $(element).slimScroll({ scrollTo: '50px' }); 45 | * **scrollBy** - Increases/decreases current scroll value by specified amount (positive or negative). Can be called on any element with slimScroll already enabled. Example: $(element).slimScroll({ scrollBy: '60px' }); 46 | * **disableFadeOut** - Disables scrollbar auto fade. When set to true scrollbar doesn't disappear after some time when mouse is over the slimscroll div.Default: false 47 | * **touchScrollStep** - Allows to set different sensitivity for touch scroll events. Negative number inverts scroll direction.Default: 200 48 | * **onScroll** - Allows to execute a function from the controllers scope on scroll event. Example: `onScroll: onScrollEvent` 49 | 50 | License 51 | ------- 52 | angular-slimscroll is released under the [MIT License](http://en.wikipedia.org/wiki/MIT_License). Feel free to use it in personal and commercial projects. 53 | -------------------------------------------------------------------------------- /angular-slimscroll.js: -------------------------------------------------------------------------------- 1 | angular.module('ui.slimscroll', []).directive('slimscroll', ['$timeout', '$window', function ($timeout, $window) { 2 | 'use strict'; 3 | 4 | return { 5 | restrict: 'A', 6 | link: function ($scope, $elem, $attr) { 7 | var off = []; 8 | var option = {}; 9 | 10 | var refresh = function () { 11 | 12 | var isEventBound = false; 13 | 14 | $timeout(function () { 15 | if (angular.isDefined($attr.slimscroll)) { 16 | option = $scope.$eval($attr.slimscroll) || {}; 17 | } else if ($attr.slimscrollOption) { 18 | option = $scope.$eval($attr.slimscrollOption) || {}; 19 | } 20 | 21 | var el = angular.element($elem); 22 | 23 | el.slimScroll({ destroy: true }); 24 | 25 | if (option.onScroll && !isEventBound) { 26 | el.slimScroll(option).bind('slimscrolling', function(e, pos) { 27 | option.onScroll(); 28 | isEventBound = true; 29 | }); 30 | } else { 31 | el.slimScroll(option); 32 | } 33 | }); 34 | }; 35 | 36 | angular.element($window).bind('resize', function() { 37 | if ($attr.slimscroll) { 38 | option = $scope.$eval($attr.slimscroll); 39 | } else if ($attr.slimscrollOption) { 40 | option = $scope.$eval($attr.slimscrollOption); 41 | } 42 | 43 | $($elem).slimScroll(option); 44 | }); 45 | 46 | var registerWatch = function () { 47 | if (angular.isDefined($attr.slimscroll) && !option.noWatch) { 48 | off.push($scope.$watchCollection($attr.slimscroll, refresh)); 49 | } 50 | 51 | if ($attr.slimscrollWatch) { 52 | off.push($scope.$watchCollection($attr.slimscrollWatch, refresh)); 53 | } 54 | 55 | if ($attr.slimscrolllistento) { 56 | off.push($scope.$on($attr.slimscrolllistento, refresh)); 57 | } 58 | }; 59 | 60 | var destructor = function () { 61 | angular.element($elem).slimScroll({destroy: true}); 62 | off.forEach(function (unbind) { 63 | unbind(); 64 | }); 65 | off = null; 66 | }; 67 | 68 | off.push($scope.$on('$destroy', destructor)); 69 | 70 | registerWatch(); 71 | } 72 | }; 73 | }]); 74 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-slimscroll", 3 | "version": "1.1.5", 4 | "authors": [ 5 | "Tony Wang ", 6 | "Greg Wang " 7 | ], 8 | "description": "An angular directive allows to use the jquery-slimscroll", 9 | "main": "./angular-slimscroll.js", 10 | "keywords": [ 11 | "angular", 12 | "slimscroll" 13 | ], 14 | "license": "MIT", 15 | "homepage": "https://github.com/ziscloud/angular-slimscroll", 16 | "ignore": [ 17 | "**/.*", 18 | "node_modules", 19 | "bower_components", 20 | "test", 21 | "tests" 22 | ], 23 | "dependencies": { 24 | "jquery": ">=1.7", 25 | "slimScroll": "~1.3.1" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-slimscroll", 3 | "version": "1.0.0", 4 | "description": "angular directive for jquery slimscroll", 5 | "main": "angular-slimscroll.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/ziscloud/angular-slimscroll.git" 9 | }, 10 | "keywords": [ 11 | "slimscroll" 12 | ], 13 | "author": "ziscloud", 14 | "contributors": [ 15 | { 16 | "name": "Krystian Kościelniak", 17 | "email": "krystiankoscielniak@gmail.com", 18 | "url": "http://kkoscielniak.xyz/" 19 | } 20 | ], 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/ziscloud/angular-slimscroll/issues" 24 | }, 25 | "homepage": "https://github.com/ziscloud/angular-slimscroll#readme" 26 | } 27 | --------------------------------------------------------------------------------