Coder Social home page Coder Social logo

ralftar / ng-mat-carousel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gbrlsnchs/material2-carousel

12.0 1.0 11.0 4.33 MB

A carousel component for Angular using Material

License: MIT License

JavaScript 2.54% TypeScript 63.40% HTML 26.64% SCSS 7.43%

ng-mat-carousel's Introduction

Material Carousel

build npm version Live demo

About

This is a carousel component for Angular using Material Design. See live demo.

History and current status

This is a fork and prolongation of the discontinued @ngmodule/material-carousel by Gabriel Sanches.

The current development goal is to keep the package secure and compatible with the most recent Angular version.

PR's are welcomed; including bugfixes, upgrades and enhancements.

Installing

npm install --save ng-mat-carousel

Importing

//...
import { MatCarouselModule } from 'ng-mat-carousel';

@NgModule({
  // ...
  imports: [
    // ...
    MatCarouselModule.forRoot(),
    // ...
  ]
})
export class AppModule {}

Usage

MatCarouselComponent

import { MatCarousel, MatCarouselComponent } from 'ng-mat-carousel';
<mat-carousel>
  ...
</mat-carousel>

Attributes

Input Type Description Default value
timings string Timings for slide animation. '250ms ease-in'
autoplay boolean Enable automatic sliding. true
interval number Autoplay's interval in milliseconds. 5000
loop boolean Enable loop through arrows. true
hideArrows boolean Hide navigation arrows. false
hideIndicators boolean Hide navigation indicators. false
color ThemePalette Color palette from Material. 'accent'
maxWidth string Maximum width. 'auto'
maintainAspectRatio boolean If true, use proportion to determine height, else slideHeight is used. true
proportion number Height proportion compared to width. 25
slideHeight string Explicit slide height. Used when maintainAspectRatio is false. '100%'
slides number Maximum amount of displayed slides.
useKeyboard boolean Enable keyboard navigation. true
useMouseWheel boolean Enable navigation through mouse wheeling. false
orientation Orientation Orientation of the sliding panel. 'ltr'
svgIconOverrides SvgIconOverrides Override default carousel icons with registered SVG icons.
ariaLabel string Carousel accessible name 'Sliding carousel'
lazyLoad booelan Lazy load content false

Size Considerations and Recommendations

By default, maintainAspectRatio is true, which means height is controlled through proportion.

If you want to have a carousel with constant height (regardless of width), you must set maintainAspectRatio to false.

By default, slideHeight is set to 100%, which will not work if the parent element height isn't defined (i.e. relative heights do not work if the parent height is auto). In that case you could pass a valid css string for slideHeight. You can use any valid css height string like 100px or 25vh.

Play around with the demo to see how you can use this carousel with or without explicit parent height.

With parent elements that have height:auto

  • use proportion if you want a carousel that resizes responsively (this is the default configuration).
  • use maintainAspectRatio="false" and a non-percentage slideHeight if you want a fixed height carousel.
  • DO NOT use relative (%) values for slideHeight; the carousel will not render.

With parent elements that have a set height

  • use maintainAspectRatio="false" if you want a fixed height carousel that fills the parent element (slideHeight is 100% by default).
  • DO NOT use maintainAspectRatio="false" and slideHeight (unless slideHeight="100%"); the carousel will not render correctly because the buttons and indicators will be positioned with respect to the parent.
  • DO NOT use proportion; this will lead to gaps or unwanted overflow.

MatCarouselSlideComponent

import { MatCarouselSlide, MatCarouselSlideComponent } from '@ngmodule/material-carousel';
<mat-carousel>
  <mat-carousel-slide>
    ...
  </mat-carousel-slide>
</mat-carousel>

Attributes

Input Type Description Default value
image string Image displayed in the slide.
overlayColor string Color of the slide's overlay. '#00000040'
hideOverlay boolean Toggle overlay on/off. false
ariaLabel string Image accessible name 'Slide'
load boolean Override lazyLoad true

How to develop and test this component

Testing

ng test carousel --watch false

Running the demo application

ng serve demo

ng-mat-carousel's People

Contributors

alerubis avatar cayan avatar chriswnewman avatar dependabot-preview[bot] avatar dependabot[bot] avatar gbrlsnchs avatar lenart91 avatar ralftar avatar sushilnyk avatar tiagoblackcode avatar tobiasstrebitzer avatar

Stargazers

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

Watchers

 avatar

ng-mat-carousel's Issues

license author

Hello.
When using the library, it is enough to include the license file from repository?
Or I need to additionally include @ralftar in my application license.txt?

Image Responsiveness Issue when viewing in laptop screen and large screens

I am using mat-carousel and mat-carousel-slide control. When viewing carousel in large screens images render perfect. But in laptop screen it starts distorting and only 70-80% of image is rendering and remaining starts cutting from edges.
I am using default maintainAspectRatio=true. No hardcoded parent width provided. Please help how to fix this. I am using Angular 9. Thanks

Upgrade to angular 15- 16

Hi
Is anyone having a clone of this library or planning to upgrade to angular v15 or v16 as this library has not been updated since long time I am getting blocked in upgrading my parent application to V16 .
Any help will be appreciated

Thanks

Upgrade plans for Angular Ivy?

Hi,
I'm not able to compile and run my Angular app as this package is no longer compatible with Angular Ivy.

I'm on the latest version (0.11.1).

image

Are there any plans to update this package?

Thanks.

Accessability

Lighthouse reports

  • ARIA input fields do not have accessible names
    • ul.carousel-list
  • Buttons do not have an accessible name

Carousel prevents vertical scroll on touch devices

The carousel currently prevents a user from scrolling on touch enabled devices. The user can swipe left/right to change slides, but not up/down for page scrolling.

Platforms tested:
-iPhone 11 Pro, iOS 14.2
-Yoga C740 14", Windows 10 Home

Unable to map the content of mat-carousel-slide using a list

I was trying to put some inner content in the carousel, the way you did in the demo. Except that, I want the content to be dynamic and based out of a list. I have used the list object for iteration of mat-carousel-slide and it renders the number of slides eual to number of item in list.

However, wen I try to bind some data from the list object in the inner content, the content just doesn't show up.
Am I missing on some property here, or this is not yet supported ?

Below is my code for reference. Using this code, I only get a blank carousel with only indicators and arrows.

[<div [style.height]="'auto'">
                        <mat-carousel timings="250ms ease-in" [autoplay]="false" interval="5000" color="accent" maxWidth="auto" slides="events.length" [loop]="true" [slideHeight]="'200px'" [maintainAspectRatio]="true" [proportion]="50" [hideArrows]="true" [hideIndicators]="false"
                            orientation="ltr">
                            <mat-carousel-slide #matCarouselSlide *ngFor="let slide of events; let i = index" overlayColor="#00000040" [hideOverlay]="true" [image]="'/assets/images/a.png'">
                                <div>{{slide.name}}</div>
                                <div>{{slide.description}}</div>
                               <!--  I want to insert some custom template or a custom component here -->


                                
                            </mat-carousel-slide>
                        </mat-carousel>]

Is there a way, I can show content or a component inside?

Upgrading from 0.7.9 to 0.11.1

I'm in the process of upgrading my app from Angular 10 to 11. While 0.7.9 seems to work just fine with Angular 11, I'd like to upgrade this package as well. However, when I run npm install [email protected] I get the following error:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"^11.2.11" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"~10.0.4" from [email protected]
npm ERR! node_modules/ng-mat-carousel
npm ERR!   ng-mat-carousel@"0.11.1" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/xxxxx/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/xxxx/.npm/_logs/2021-04-23T16_44_01_703Z-debug.log

I can't for the life of me figure out where @angular/common@"~10.0.4 is coming from. My package.json has "@angular/common": "^11.2.11". This project has "@angular/common": "^11.0.2". Any thoughts on where this could be coming from?

Swipe Not Working On Angular 10

dependencies using:
"dependencies": { "@angular-material-extensions/password-strength": "^6.0.0", "@angular/animations": "~10.0.5", "@angular/cdk": "^10.1.0", "@angular/common": "~10.0.5", "@angular/compiler": "~10.0.5", "@angular/core": "~10.0.5", "@angular/fire": "^6.0.2", "@angular/flex-layout": "^9.0.0-beta.31", "@angular/forms": "~10.0.5", "@angular/material": "^10.1.0", "@angular/platform-browser": "~10.0.5", "@angular/platform-browser-dynamic": "~10.0.5", "@angular/router": "~10.0.5", "bootstrap": "^4.5.0", "firebase": "^7.17.1", "hammerjs": "^2.0.8", "mat-video": "^2.8.1", "ng-mat-carousel": "^0.7.7", "ngx-auth-firebaseui": "^4.4.0", "password-strength": "github:angular-material-extensions/password-strength", "rxjs": "~6.6.0", "tslib": "^2.0.0", "zone.js": "~0.10.2" },

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.