cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Navigate between Views using CSS

Velkumar
18-Opal

Navigate between Views using CSS

Hello all,

 

Is there any possibility to navigate between different views using CSS.

 

Thanks in Advance.

 

Regards,

VR

1 ACCEPTED SOLUTION

Accepted Solutions

Something like this should work:

 

window.addEventListener("orientationchange", function() {
  alert("rotate!");

  var width = window.innerWidth;
  var height = window.innerHeight;
  // assume your two views are named "Portrait" and "Landscape"
  if(width > height) {
    $scope.app.fn.navigate("Landscape");
  }
  else {
    $scope.app.fn.navigate("Portrait");
  }
});

Note that you'll only want to add this once, in your initial view, since it attaches to the top level window object, and it will trigger no matter which view is active. You don't need separate copies in each view.js panel.

View solution in original post

5 REPLIES 5

I don't see how that would work with CSS, but you can certainly do it with Javascript. You can also do it using a UI widget (like a button) with a binding to the navigate service on the view.

Hello @ClayHelberg 

 

Thanks for your reply. My use case to switch between views based on Orientation of the device. I tried using using javascript to find orientation of the device, but it doesn't work. So I'm looking in CSS to achieve this.

 

/VR

TomasCharvat
14-Alexandrite
(To:Velkumar)

Hello Velkumar

 

maybe this will help you for detect an orientation:

$scope.getOrientation = function() {
  var width = window.innerWidth;
  var height = window.innerHeight;
  /**/
  console.info("display size: " + width + "x" + height);
  /**/
  var orientation = "";
  if(width > height) {
    orientation = "landscape";
  }
  else {
    orientation = "portrait";
  }
  console.info(orientation);
  return orientation;
}

 

Regards

 

Tomas

 

Something like this should work:

 

window.addEventListener("orientationchange", function() {
  alert("rotate!");

  var width = window.innerWidth;
  var height = window.innerHeight;
  // assume your two views are named "Portrait" and "Landscape"
  if(width > height) {
    $scope.app.fn.navigate("Landscape");
  }
  else {
    $scope.app.fn.navigate("Portrait");
  }
});

Note that you'll only want to add this once, in your initial view, since it attaches to the top level window object, and it will trigger no matter which view is active. You don't need separate copies in each view.js panel.

InfinityX
14-Alexandrite
(To:Velkumar)

its not possible with CSS. its possible with binding of button or toggle button with navigate property

Top Tags