Guest User

Untitled

a guest
Jan 16th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import { Action } from '@ngrx/store';
  2. import { type } from '../util/util';
  3.  
  4. export const ActionTypes = {
  5. SET_SCREEN: type<'SET_SCREEN'>('SET_SCREEN'),
  6. };
  7. const MOBILE_MAX_WIDTH = 425; //Adjust as needed
  8. const TABLET_MAX_WIDTH = 1024; //Adjust as needed
  9.  
  10. // Action type for screen
  11. export class SetScreen implements Action {
  12. type = ActionTypes.SET_SCREEN;
  13. payload: Readonly<{
  14. mobile: boolean,
  15. tablet: boolean,
  16. desktop: boolean
  17. }>;
  18.  
  19. public constructor(width: number) {
  20. const mobile = width <= MOBILE_MAX_WIDTH;
  21. const tablet = width <= TABLET_MAX_WIDTH && width > MOBILE_MAX_WIDTH;
  22. this.payload = {
  23. mobile,
  24. tablet,
  25. desktop: !mobile && !tablet,
  26. };
  27. }
  28. }
  29.  
  30. export type Actions = SetScreen;
Add Comment
Please, Sign In to add comment