ng-click not working in AngularJS, Cordova - angularjs

We are writing an application in Ionic, Cordova, AngularJS.
My code is here https://jsfiddle.net/sweety1112/wag7ye4b/1/
My problem is that ui-sref or ng-click is not working as expected. Are there any errors?
$stateProvider
.state('app', {
url: '',
abstract: true,
templateUrl: 'HomePage.html'
})
.state('app.home', {
url: '/home',
templateUrl:'templates/HomeScreen.html',
controller: 'HomePageCtrl'
})
.state('app.scan',
{ parent:'app',
url: '/scan',
templateUrl: 'templates/Scan.html'
// controller: 'SettingsController'
})
.state('app.help', {
url: '/help',
templateUrl:'templates/Help.html'
})
In HTML i have
$scope.funOne=function(){
alert("Button Clicked"); };
Then this should be called from the html
<div> <br/><br/><br/><br/><br/><br/><div ng-click="funOne()"><h1> Home Screen</h1> </div>
<div class="centerButton" ng-click="funOne()">
<a ui-href="app.help"> <img src='assets/img/start_btn.png'/> </a>
<p>START</p>
</div>
ng-click is working from the div which has Home Screen but it is not working on Image. Even ui-sref is not working on the image.

Updated the fiddle with the css classes as well changed the ng-click position. Your css is conflicting with the ng-click and hence needs to be at the parent level.
Updated Fiddle
Css Changed:
.bar-positive {
background-color: #C12537;
border: none;
}
.container {
width:550px;
height:550px;
position:relative;
z-index: -1;
display:block;
}
.container .left, .right div p {
top: 44%;
left: -14%;
}
.container .right {
transform: rotate(90deg);
}
.rotate div p {
position:absolute;
margin:0;
padding:0;
font-family:'Roboto';
font-size: 22px;
color: #FFFFFF;
top:27%;
left:20%;
}
.text {
transform: rotate(360deg);
}
.container img {
position:absolute;
}
.rotate img {
width:100%;
/*-webkit-transform-origin: 70% 105%;*/
z-index: -1;
position:relative;
}
.rotate {
width:72%;
transition: transform 0.5s linear;
transform-origin: 70% 105%;
position:absolute;
}
.bottom img {
/*-webkit-transform: rotate(180deg);*/
z-index: -1;
margin-top: 308px;
margin-left: 141px;
transform: rotate(180deg);
}
.left img {
transform: rotate(270deg);
z-index: -1;
}
.right img {
/*-webkit-transform: rotate(90deg);*/
z-index: -1;
}
.rotate.right div p {
top:22%;
left:9%;
transform: rotate(270deg);
}
.rotate.bottom div p {
position: absolute;
margin: 0;
padding: 0;
font-family:'Roboto';
font-size: 22px;
color: #FFFFFF;
top: 79%;
left: 100%;
}
.rotate.left div p {
top:78%;
left:26%;
transform: rotate(360deg);
}
/*New style**/
.rotate div {
position: absolute;
padding:0;
margin:0;
width:100%;
height:100%;
left:0;
right:0;
top:0;
bottom:0;
transition: transform 0.5s linear;
}
.flex-container {
height: 100%;
padding: 0;
margin: 0;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.centerButton img, .centerButton p {
position:absolute;
width:100%;
top:-50%;
left:-50%;
right:-50%;
bottom:-50%;
margin:auto;
}
.centerButton p {
height:10%;
text-align:center;
font-family:'Roboto';
font-size: 22px;
color: #FFFFFF;
}
.centerButton {
width:50%;
height:50%;
margin:auto;
position:absolute;
top:-45%;
left:-50%;
right:-52%;
bottom:-50%;
}
UPDATE:
Your z-index in the css class was giving the issue. Corrected that in the updated fiddle
CSS for reference:
.bar-positive {
background-color: #C12537;
border: none;
}
.container {
width:550px;
height:550px;
position:relative;
z-index: 9999;
display:block;
}
.container .left, .right div p {
top: 44%;
left: -14%;
}
.container .right {
transform: rotate(90deg);
}
.rotate div p {
position:absolute;
margin:0;
padding:0;
font-family:'Roboto';
font-size: 22px;
color: #FFFFFF;
top:27%;
left:20%;
}
.text {
transform: rotate(360deg);
}
.container img {
position:absolute;
}
.rotate img {
width:100%;
/*-webkit-transform-origin: 70% 105%;*/
z-index: 9999;
position:relative;
}
.rotate p {
z-index:9999;
}
.rotate {
width:72%;
transition: transform 0.5s linear;
transform-origin: 70% 105%;
position:absolute;
}
.bottom img {
/*-webkit-transform: rotate(180deg);*/
z-index: 9999;
margin-top: 308px;
margin-left: 141px;
transform: rotate(180deg);
}
.left img {
transform: rotate(270deg);
z-index: 9999;
}
.right img {
/*-webkit-transform: rotate(90deg);*/
z-index: 9999;
}
.rotate.right div p {
top:22%;
left:9%;
transform: rotate(270deg);
}
.rotate.bottom div p {
position: absolute;
margin: 0;
padding: 0;
font-family:'Roboto';
font-size: 22px;
color: #FFFFFF;
top: 79%;
left: 100%;
}
.rotate.left div p {
top:78%;
left:26%;
transform: rotate(360deg);
}
/*New style**/
.rotate div {
position: absolute;
padding:0;
margin:0;
width:100%;
height:100%;
left:0;
right:0;
top:0;
bottom:0;
transition: transform 0.5s linear;
}
.flex-container {
height: 100%;
padding: 0;
margin: 0;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.centerButton img, .centerButton p {
position:absolute;
width:100%;
top:-50%;
left:-50%;
right:-50%;
bottom:-50%;
margin:auto;
}
.centerButton p {
height:10%;
text-align:center;
font-family:'Roboto';
font-size: 22px;
color: #FFFFFF;
}
.centerButton {
width:50%;
height:50%;
margin:auto;
position:absolute;
top:-45%;
left:-50%;
right:-52%;
bottom:-50%;
}

Related

Lazy Loading Photos For A Smoother Mobile Website

Below are the HTML, CSS, and Javascript I use on my website. I'm using a MAMP server (via an apache) to get it online and have no problems getting it to run over wi-fi. However, when I try to access it via my mobile network the website crashes after viewing a few pages. I have port-forwarded my router.
I think (and please correct me if I'm wrong) that too much is loading on the page at once, which is what is making the website crash when testing it on a mobile network. How would I set up the page so that the photos lazy load? If anyone has any advice it'd be much appreciated.
<!DOCTYPE html>
<html lang="en">
<meta name="viewport" content="width=device-width, initial-scale=1.0;" charset="utf-8">
<body>
<style>html{visibility: hidden; opacity: 0;}</style>
<title>MORIKOBOSHI・</title>
<div class="page-wrap">
<div class="cp_cont">
<input id="cp_toggle03" type="checkbox"/>
<div class="cp_mobilebar">
<label for="cp_toggle03" class="cp_menuicon">
<span></span>
</label>
</div>
<label id="h-menu_black" class="cp_toggle03" for="cp_menuicon"></label>
<div id="body" class="noscroll"></div>
<header class="cp_offcm03">
<nav>
<ul style="text-align: center; margin-left: 210px; overflow: hidden;">
<li style="border-bottom: .05px solid lightgray;">Home</li>
<li style="border-bottom: .05px solid lightgray;">Blog</li>
<li style="border-bottom: .05px solid lightgray;">About This Website</li>
<li style="border-bottom: .05px solid lightgray;">Bibliography</li>
<div class="searchbar">
<form id="frmSearch" class="search2" method="get" action="default.html" style=" padding-right: 10px; padding-top: 20px; text-align: center; position: inline;">
<input class="search2" id="txtSearch" type="text" placeholder="Custom Google Search" name="serach_bar" size="31" maxlength="255" value="" style="top: 185px; width: 180px; height: 26px;">
<input class="search1" type="submit" name="submition" value="Search" style="padding-left: 5px; top: 153px; height: 25px; width: 50px; display: inline-flex; justify-content: center;">
<input class="search2" type="hidden" name="sitesearch" value="default.html">
</form>
</div>
<script type="text/javascript">
document.getElementById('frmSearch').onsubmit = function() {
window.location = 'http://www.google.com/search?q=site:morikoboshi.com' + document.getElementById('txtSearch').value;
return false;
}
</script>
<script>
document.getElementById('cp_toggle03').onchange = function() {
if (document.getElementById('cp_toggle03').checked) {
document.body.style.overflow = "hidden";
} else {
document.body.style.overflow = "";
}
}
if(!!window.performance && window.performance.navigation.type == 2)
{
window.location.reload();
}
</script>
</ul>
</nav>
</header>
<div class="setsumei">
<br><br><h1 style="text-align: center; font-size: 40px;">◯◯◯◯</h1>
<br><p style="text-align: justify; font-size: 16px;"></p>
<p style="text-align: center; font-size: 13px;">Author: ◯◯◯◯</p>
<p style="text-align: center; font-size: 13px;">Photos/Videos Taken:◯◯◯◯/◯◯/◯◯</p>
<br><br><p style="text-align: justify; font-size: 16px;">
#
</p>
</div>
<br><br><div class="image">
<img src="#" alt="#" width="90%">
<br><br><img src="#" alt="#" width="90%">
<br><br><img src="#" alt="#" width="90%">
<br><br><img src="#" alt="#" width="90%">
<br><br><img src="#" alt="#" width="90%">
<br><br><img src="#" alt="#" width="90%">
<br><br><img src="#" alt="#" width="90%">
<br><br><img src="#" alt="#" width="90%">
<br><br><img src="#" alt="#" width="90%">
<br><br><img src="#" alt="#" width="90%">
</div>
<br><br><footer class="site-footer" style="font-size: 12px;">MORIKOBOSHI© | 日本語</footer>
</div>
</div>
<style>
html {visibility: visible;
opacity: 1;}
.body{background-color: white;
font-family: sans-serif;}
.searchbar{float: right;}
.image{text-align: center;}
.setsumei{margin-left: 20px;
margin-right: 20px;}
.footer{width: 100%;
height: 40px;
text-align: center;
border-top: 1px solid black;
position: absolute;
bottom: 0;
padding: 10px;}
.page-wrap {
min-height: 100%;
/* equal to footer height */
margin-bottom: -40px;
}
.page-wrap:after {
content: "";
display: block;
}
.site-footer, .page-wrap:after {
/* .push must be the same height as footer */
height: 20px;
}
.site-footer {
text-align: center;
border-top: 1px solid black;
padding: 10px;
}
*, *:before, *:after {
padding-left: 0;
margin: 0;
box-sizing: border-box;
}
ol, ul {
list-style: none;
}
a {
text-decoration: none;
color: black;
}
.cp_cont {
height: auto;
}
/* menu */
.cp_offcm03 {
position: relative;
z-index: 5000;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: auto;
width: 100%;
height: auto;
padding-top: 0;
-webkit-transition: transform 0.3s ease-in;
transition: transform 0.3s ease-in;
text-align: center;
color: black;
background-color: white;
}
.cp_offcm03 nav,
.cp_offcm03 ul {
height: 100%;
}
.cp_offcm03 li {
display: inline-block;
margin-right: -6px;
}
.cp_offcm03 a {
display: block;
padding: 15px 45px;
margin-bottom: -5px;
-webkit-transition: background-color .3s ease-in;
transition: background-color .3s ease-in;
}
.cp_offcm03 a:hover {
background-color: lightgray;
}
/* menu toggle */
#cp_toggle03 {
display: none;
}
#cp_toggle03:checked ~ .cp_offcm03 {
-webkit-transform: translateX(0);
transform: translateX(0);
}
#cp_toggle03:checked ~ .cp_container {
-webkit-transform: translateX(0);
transform: translateX(0);
}
.cp_mobilebar {
display: none;
}
/* content */
.cp_container {
position: relative;
top: 0;
padding: 35px auto;
-webkit-transition: transform .3s ease-in;
transition: transform .3s ease-in;
}
.cp_content {
margin: 0 auto;
padding: 20px;
height: 65vh;
text-align: center;
}
#media (max-width: 1130px)and (min-width: 280px) {
/* menu */
.cp_offcm03 {
position: fixed;
left: -250px;
overflow-y: hidden;
width: 250px;
height: 100%;
padding-top: 40px;
color: black;
background-color: white;
z-index: 1000;
}
.cp_offcm03 nav {
background: white;
border-right: 0.5px solid lightgray;
margin-left: -210px;
}
.cp_offcm03 li {
display: block;
margin-right: 0;}
.cp_offcm03 a {
padding: 20px;
}
/* menu toggle */
.cp_mobilebar {
display: block;
z-index: 2000;
position: relative;
top: 0;
left: 0;
padding: 0 25px;
width: 100%;
height: 40px;
background-color: white;
border-bottom: .05px solid lightgray;
}
.cp_menuicon {
display: block;
position: relative;
width: 25px;
height: 100%;
cursor: pointer;
-webkit-transition: transform .3s ease-in;
transition: transform .3s ease-in;
}
.cp_menuicon > span {
display: block;
position: absolute;
top: 55%;
margin-top: -0.3em;
width: 100%;
height: 0.2em;
border-radius: 1px;
background-color: black;
-webkit-transition: transform .3s ease;
transition: transform .3s ease;
}
.cp_menuicon > span:before,
.cp_menuicon > span:after {
content: "";
position: absolute;
width: 100%;
height: 100%;
border-radius: 1px;
background-color: black;
-webkit-transition: transform .3s ease-in;
transition: transform .3s ease-in;
}
.cp_menuicon > span:before {
-webkit-transform: translateY(-0.6em);
transform: translateY(-0.6em);
}
.cp_menuicon > span:after {
-webkit-transform: translateY(0.6em);
transform: translateY(0.6em);
}
#cp_toggle03:checked + .cp_mobilebar .cp_menuicon {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
#cp_toggle03:checked + .cp_mobilebar span:before,
#cp_toggle03:checked + .cp_mobilebar span:after {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
#cp_toggle03:checked ~ .cp_offcm03 {
-webkit-transform: translateX(100%);
transform: translateX(100%);
}
#cp_toggle03:checked ~ .cp_container {
-webkit-transform: translateX(250px);
transform: translateX(250px);
}
input:checked ~ #h-menu_black {
display: block;/*カバーを表示*/
opacity: .6;
}
#h-menu_black {
display: none;
position: fixed;
z-index: 999;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: black;
opacity: 0;
transition: .7s ease-in-out;
}
/* content */
.cp_container {
top: 60px;
height: 92vh;
text-align: center;
}
.noscroll{
overflow: hidden;
position: fixed;
}
</style>
</body>
</html>

Is it possible to use the same React component with different CSS, using css modules?

I found the React CSS modules usefull, but having problem when I tried to reuse the same component with a little modified css I stuck. For example I created Neon glowing button, but now need to change only the width of the Button and some additional small changes in the css.
The only option I see is component without css and for every different case need to rewrite the whole css. Is there a smarter way?
import React from "react";
import styles from "./index.module.css";
import { Link } from "react-router-dom";
const GlowingButton = ({ title, path }) => {
return (
<div className={styles.buttonWrapper}>
<Link className={styles.button} to={path}>
<button className={styles["glow-on-hover"]}>{title}</button>
</Link>
</div>
);
};
export default GlowingButton;
And here is index.module.css
.buttonWrapper {
margin: 0px;
padding: 0px;
display: flex;
justify-content: center;
align-items: center;
background: transparent;
font-family: "consolas";
}
.button {
margin: 0;
padding: 0;
width: 80%;
height: 8vh;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
background: #100f;
text-decoration: none;
}
.glow-on-hover {
width: 400px;
height: 50px;
border: none;
outline: none;
color: #fff;
background: #111;
cursor: pointer;
position: relative;
z-index: 0;
border-radius: 10px;
}
.glow-on-hover:before {
content: "";
background: linear-gradient(
45deg,
#ff0000,
#ff7300,
#fffb00,
#48ff00,
#00ffd5,
#002bff,
#7a00ff,
#ff00c8,
#ff0000
);
position: absolute;
top: -2px;
left: -2px;
background-size: 400%;
z-index: -1;
filter: blur(5px);
width: calc(100% + 4px);
height: calc(100% + 4px);
animation: glowing 20s linear infinite;
opacity: 0;
transition: opacity 0.3s ease-in-out;
border-radius: 10px;
}
.glow-on-hover:active {
color: #000;
}
.glow-on-hover:active:after {
background: transparent;
}
.glow-on-hover:hover:before {
opacity: 1;
}
.glow-on-hover:after {
z-index: -1;
content: "";
position: absolute;
width: 100%;
height: 100%;
background: #111;
left: 0;
top: 0;
border-radius: 10px;
}
#keyframes glowing {
0% {
background-position: 0 0;
}
50% {
background-position: 400% 0;
}
100% {
background-position: 0 0;
}
}

How to convert from TSX to JSX in this Codesandbox

I am learning React and JavaScript and now I have this CodeSandbox but I can't convert it to JavaScript React I have tried this for the Card Component:
import React, { useState } from "react";
const Card = props => {
const [expanded, setExpanded] = useState(false);
const RenderCard = (className) => {
return (
<div
className={`card ${className}${expanded ? " expanded" : ""}`}
onClick={() => {
setExpanded(!expanded);
}}
>
<div className="image">
<img alt="digger" src={props.image} />
</div>
<div className="info">
<div
className="bg1"
style={{ backgroundImage: "url('" + props.image + "')" }}
/>
<div
className="bg2"
style={{ backgroundImage: "url('" + props.image + "')" }}
/>
<div
className="bg3"
style={{ backgroundImage: "url('" + props.image + "')" }}
/>
<h1>JCB OES System</h1>
<h2>Report Number #1</h2>
<h3>Load lifter work area</h3>
<div className="button">Open</div>
</div>
</div>
);
};
return (
<div className={`card-container${expanded ? " expanded" : ""}`}>
{expanded && <div className="background" />}
{<RenderCard className="card1"/>}
{<RenderCard className="card2"/>}
</div>
);
};
export default Card;
And I show the Card like this. It's very simple, it's just that when I click a card it does not pop up like the CodeSandbox does.
import Card from "./Card";
import "./styles.scss";
const CreateContent = () => {
return (
<div className="app">
<link rel="stylesheet" href="https://use.typekit.net/jli8mqj.css" />
<Card image="https://www.thetimes.co.uk/imageserver/image/methode%2Fsundaytimes%2Fprodmigration%2Fweb%2Fbin%2Fbeae8dfb-0a41-4f8e-b076-ffd68417287b.jpg?crop=1024%2C683%2C0%2C0&resize=685" />
<Card image="https://www.virginexperiencedays.co.uk/content/img/product/large/PJCBRA__01.jpg" />
<Card image="https://www.toyfarmers.co.uk/images/britains-jcb-3cx-backhoe-loader.jpg" />
<Card image="https://seatylive.blob.core.windows.net/eventimages/2019-Aug-20-Tue_18-37-31-969.png" />
</div>
);
};
export default CreateContent;
The styles is the same, with no changes: I understand that the expanded background when set to expanded=true using the hook that the scss style for background should be in effect but all I get is a black screen.
.app {
font-family: sans-serif;
text-align: center;
padding: 4em 0;
}
* {
box-sizing: border-box;
padding: 0;
margin: 0;
border: 0;
}
.card-container {
font-family: niveau-grotesk, sans-serif !important;
position: relative;
z-index: 0;
&.expanded {
z-index: 3;
#keyframes fade-in {
0% { opacity: 0; }
100% { opacity: 1; }
}
.background {
animation: fade-in .3s ease-out;
z-index: 2;
position: fixed;
background: black;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
}
}
.card {
margin: 0 auto;
width: 25em;
cursor: pointer;
border-radius: .5em;
box-shadow: 0 50px 100px -20px rgba(50,50,93,.25),
0 30px 60px -30px rgba(0,0,0,.3),
0 -18px 60px -10px rgba(0,0,0,.03);
margin-bottom: 4em;
&.card2 {
transition: .2s ease-out;
position: absolute;
top: 0;
width: 25em;
left: 50%;
z-index: 4;
transform: translateX(-50%);
&.expanded {
width: 40em;
}
}
.image {
img {
display: block;
border-top-left-radius: .5em;
border-top-right-radius: .5em;
width: 100%;
}
}
$button-color: rgb(87, 87, 228);
&:hover {
.info .button {
color: white;
background: $button-color;
}
}
.info {
background: white;
position: relative;
border-bottom-left-radius: .5em;
border-bottom-right-radius: .5em;
overflow: hidden;
padding: .9em 1.2em;
text-align: left;
$darkness: 0;
&:after {
content: '';
position: absolute;
top: -20%;
left: -20%;
right: -20%;
bottom: -20%;
height: 140%;
width: 140%;
// filter: blur(8px);
// -webkit-filter: blur(8px);
background: linear-gradient(to right,
rgba(0, 0, 0, 0.4) 30%,
rgba(0, 0, 0, 0) 100%);
}
.bg1, .bg2 {
position: absolute;
top: -20%;
left: -20%;
right: -20%;
bottom: -20%;
height: 140%;
width: 140%;
z-index: 0;
background-position: center;
background-repeat: no-repeat;
background-size: 100%;
transform: rotate(180deg);
filter: blur(16px);
}
.bg2 {
background-position: bottom;
transform: rotate(0deg);
opacity:0.4;
}
.bg3 {
background-position: top;
transform: rotate(180deg);
opacity:0.4;
}
.button {
transition: .2s ease-out;
text-transform: uppercase;
line-height: 1.2em;
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 1.8em;
z-index: 1;
background: white;
border-radius: 1em;
padding: .4em 1.1em;
font-weight: 600;
color: $button-color;
}
h1, h2, h3 {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
max-width: 13em;
color: white;
position: relative;
z-index: 1;
text-shadow: 1px 1px 1px rgba(0,0,0,0.8);
}
h1 {
line-height: .8em;
letter-spacing: .03em;
font-size: 1.1em;
font-weight: 900;
padding: .1em 0;
}
h2 {
letter-spacing: .02em;
font-size: 1.0em;
font-weight: 400;
padding: .1em 0;
opacity: 0.6;
}
h3 {
letter-spacing: .02em;
font-size: .9em;
font-weight: 400;
padding: .1em 0;
}
}
}
}
What am I missing?
To swap your Code Sandbox from TypeScript to JavaScript you should just need to:
Remove all typescript specific syntax from your ".ts" and ".tsx" files (interfaces, typings, etc)
Change all the file extensions to their JavaScript equivalent i.e. ".ts" -> ".js" and ".tsx" -> ".jsx".
Update the "main" property of the "package.json" file to point to the renamed entry point. i.e. "src/index.jsx".
I created a quick CodeSandbox with this already done.

Fontawesome 5 SVG icons not staying inline with other elements like other icons

Weird issue with fontawesome icons and semantic UI that I can't figure out. If I use the included icons with semantic UI everything works great and displays in the proper place.
If I use the fontawesome react component the icon ends up in some seemingly random place
code sandbox show the example https://codesandbox.io/embed/semantic-ui-example-i7o3w
Any help is much appreciated
It's because font-awesome icons are unstyled SVGs while Semantic-UI looks for a styled i element to display a font specific icon via a string.
To work around it, you'll basically have to do something like this:
<Search
value="FA comp - broken"
icon={
<i className="icon">
<FontAwesomeIcon
style={{ marginTop: 13 }} // alternatively you can do: position: "relative", top: 13
icon="thumbs-down"
/>
</i>
}
/>
Semantic-UI specifically looks for an i.icon element + classname to add styles to it: .ui.icon.input > i.icon. One of the many downsides of using a UI framework is that you're forced to work within its confined architecture.
As follow up to Matt's great help - I dug in to the semantic-ui LESS library and figured out the overrides needed for fontawesome to behave pretty well with it.
here are the icon.overrides and input.overrides with a few notes that are needed for fontawesome to behave nicely.
With the newest fontawesome version (5.10.2) the sizing issues are generally addressed in-library so most display issues that I previous encountered are not a problem.
/* site/elements/input.overrides */
/* just the overrides to replace i for ANYTHING icon so we can use font awesome
semantic always assumes the icon is ONLY an i - that's it - we so far have a link / an A and a span and an svg element
for semantic - SO I'm just going to pull out all the hardcodes and just go with .icon and see how that behaves
just make sure the top level element for the 'icon' has the class 'icon' and you *should* be good don't put icon on every
child element - or rather you don't have to...
SVGs get squared nicely - anything else will need moving
*/
/*--------------------
Loading
---------------------*/
.ui.loading.loading.input > .icon:before {
position: absolute;
content: '';
top: 50%;
left: 50%;
margin: #loaderMargin;
width: #loaderSize;
height: #loaderSize;
border-radius: #circularRadius;
border: #loaderLineWidth solid #loaderFillColor;
}
.ui.loading.loading.input > .icon:after {
position: absolute;
content: '';
top: 50%;
left: 50%;
margin: #loaderMargin;
width: #loaderSize;
height: #loaderSize;
animation: button-spin #loaderSpeed linear;
animation-iteration-count: infinite;
border-radius: #circularRadius;
border-color: #loaderLineColor transparent transparent;
border-style: solid;
border-width: #loaderLineWidth;
box-shadow: 0px 0px 0px 1px transparent;
}
/* Transparent Icon */
.ui.transparent.icon.input > .icon {
width: #transparentIconWidth;
}
/*--------------------
Icon
---------------------*/
.ui.icon.input > .icon {
cursor: default;
position: absolute;
line-height: 1;
text-align: center;
top: 0px;
right: 0px;
margin: 0em;
height: 100%;
width: #iconWidth;
opacity: #iconOpacity;
border-radius: 0em #borderRadius #borderRadius 0em;
transition: #iconTransition;
}
.ui.icon.input > .icon:not(.link) {
pointer-events: none;
}
.ui.icon.input > .icon:before,
.ui.icon.input > .icon:after {
left: 0;
position: absolute;
text-align: center;
top: 50%;
width: 100%;
margin-top: #iconOffset;
}
.ui.icon.input > .link.icon {
cursor: pointer;
}
.ui.icon.input > .circular.icon {
top: #circularIconVerticalOffset;
right: #circularIconHorizontalOffset;
}
/* Left Icon Input */
.ui[class*="left icon"].input > .icon {
right: auto;
left: #borderWidth;
border-radius: #borderRadius 0em 0em #borderRadius;
}
.ui[class*="left icon"].input > .circular.icon {
right: auto;
left: #circularIconHorizontalOffset;
}
/* Focus */
.ui.icon.input > input:focus ~ .icon {
opacity: 1;
}
/* site/elements/icon.overrides */
/*!
refactored these to be a svg rather than i . so they can be svg icons for font awesome
straight copy and paste from https://github.com/Semantic-Org/Semantic-UI-LESS/blob/master/definitions/elements/icon.less
regex find and replace find: \ni. replace \nsvg.
DO NOT COPY THE LAST LINE OF THE FILE - otherwise you'll end up in an endless loop compiling
also don't copy the theme section - it's unneeded
*/
svg.icon {
display: inline-block;
opacity: #opacity;
margin: 0em #distanceFromText 0em 0em;
width: #width;
height: 100%;
font-family: 'Icons';
font-style: normal;
font-weight: #normal;
text-decoration: inherit;
text-align: center;
speak: none;
font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
backface-visibility: hidden;
}
svg.icon:before {
background: none !important;
}
/*******************************
Types
*******************************/
/*--------------
Loading
---------------*/
svg.icon.loading {
height: 1em;
line-height: 1;
animation: icon-loading #loadingDuration linear infinite;
}
#keyframes icon-loading {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
/*******************************
States
*******************************/
svg.icon.hover {
opacity: 1 !important;
}
svg.icon.active {
opacity: 1 !important;
}
svg.emphasized.icon {
opacity: 1 !important;
}
svg.disabled.icon {
opacity: #disabledOpacity !important;
}
/*******************************
Variations
*******************************/
/*-------------------
Fitted
--------------------*/
svg.fitted.icon {
width: auto;
margin: 0em !important;
}
/*-------------------
Link
--------------------*/
svg.link.icon, svg.link.icons {
cursor: pointer;
opacity: #linkOpacity;
transition: opacity #defaultDuration #defaultEasing;
}
svg.link.icon:hover, svg.link.icons:hover {
opacity: 1 !important;
}
/*-------------------
Circular
--------------------*/
svg.circular.icon {
border-radius: 500em !important;
line-height: 1 !important;
padding: #circularPadding !important;
box-shadow: #circularShadow;
width: #circularSize !important;
height: #circularSize !important;
}
svg.circular.inverted.icon {
border: none;
box-shadow: none;
}
/*-------------------
Flipped
--------------------*/
svg.flipped.icon,
svg.horizontally.flipped.icon {
transform: scale(-1, 1);
}
svg.vertically.flipped.icon {
transform: scale(1, -1);
}
/*-------------------
Rotated
--------------------*/
svg.rotated.icon,
svg.right.rotated.icon,
svg.clockwise.rotated.icon {
transform: rotate(90deg);
}
svg.left.rotated.icon,
svg.counterclockwise.rotated.icon {
transform: rotate(-90deg);
}
/*-------------------
Bordered
--------------------*/
svg.bordered.icon {
line-height: 1;
vertical-align: baseline;
width: #borderedSize;
height: #borderedSize;
padding: #borderedVerticalPadding #borderedHorizontalPadding !important;
box-shadow: #borderedShadow;
}
svg.bordered.inverted.icon {
border: none;
box-shadow: none;
}
/*-------------------
Inverted
--------------------*/
/* Inverted Shapes */
svg.inverted.bordered.icon,
svg.inverted.circular.icon {
background-color: #black !important;
color: #white !important;
}
svg.inverted.icon {
color: #white;
}
/*-------------------
Colors
--------------------*/
/* Red */
svg.red.icon {
color: #red !important;
}
svg.inverted.red.icon {
color: #lightRed !important;
}
svg.inverted.bordered.red.icon,
svg.inverted.circular.red.icon {
background-color: #red !important;
color: #white !important;
}
/* Orange */
svg.orange.icon {
color: #orange !important;
}
svg.inverted.orange.icon {
color: #lightOrange !important;
}
svg.inverted.bordered.orange.icon,
svg.inverted.circular.orange.icon {
background-color: #orange !important;
color: #white !important;
}
/* Yellow */
svg.yellow.icon {
color: #yellow !important;
}
svg.inverted.yellow.icon {
color: #lightYellow !important;
}
svg.inverted.bordered.yellow.icon,
svg.inverted.circular.yellow.icon {
background-color: #yellow !important;
color: #white !important;
}
/* Olive */
svg.olive.icon {
color: #olive !important;
}
svg.inverted.olive.icon {
color: #lightOlive !important;
}
svg.inverted.bordered.olive.icon,
svg.inverted.circular.olive.icon {
background-color: #olive !important;
color: #white !important;
}
/* Green */
svg.green.icon {
color: #green !important;
}
svg.inverted.green.icon {
color: #lightGreen !important;
}
svg.inverted.bordered.green.icon,
svg.inverted.circular.green.icon {
background-color: #green !important;
color: #white !important;
}
/* Teal */
svg.teal.icon {
color: #teal !important;
}
svg.inverted.teal.icon {
color: #lightTeal !important;
}
svg.inverted.bordered.teal.icon,
svg.inverted.circular.teal.icon {
background-color: #teal !important;
color: #white !important;
}
/* Blue */
svg.blue.icon {
color: #blue !important;
}
svg.inverted.blue.icon {
color: #lightBlue !important;
}
svg.inverted.bordered.blue.icon,
svg.inverted.circular.blue.icon {
background-color: #blue !important;
color: #white !important;
}
/* Violet */
svg.violet.icon {
color: #violet !important;
}
svg.inverted.violet.icon {
color: #lightViolet !important;
}
svg.inverted.bordered.violet.icon,
svg.inverted.circular.violet.icon {
background-color: #violet !important;
color: #white !important;
}
/* Purple */
svg.purple.icon {
color: #purple !important;
}
svg.inverted.purple.icon {
color: #lightPurple !important;
}
svg.inverted.bordered.purple.icon,
svg.inverted.circular.purple.icon {
background-color: #purple !important;
color: #white !important;
}
/* Pink */
svg.pink.icon {
color: #pink !important;
}
svg.inverted.pink.icon {
color: #lightPink !important;
}
svg.inverted.bordered.pink.icon,
svg.inverted.circular.pink.icon {
background-color: #pink !important;
color: #white !important;
}
/* Brown */
svg.brown.icon {
color: #brown !important;
}
svg.inverted.brown.icon {
color: #lightBrown !important;
}
svg.inverted.bordered.brown.icon,
svg.inverted.circular.brown.icon {
background-color: #brown !important;
color: #white !important;
}
/* Grey */
svg.grey.icon {
color: #grey !important;
}
svg.inverted.grey.icon {
color: #lightGrey !important;
}
svg.inverted.bordered.grey.icon,
svg.inverted.circular.grey.icon {
background-color: #grey !important;
color: #white !important;
}
/* Black */
svg.black.icon {
color: #black !important;
}
svg.inverted.black.icon {
color: #lightBlack !important;
}
svg.inverted.bordered.black.icon,
svg.inverted.circular.black.icon {
background-color: #black !important;
color: #white !important;
}
/*-------------------
Sizes
--------------------*/
svg.mini.icon,
svg.mini.icons {
line-height: 1;
font-size: #mini;
}
svg.tiny.icon,
svg.tiny.icons {
line-height: 1;
font-size: #tiny;
}
svg.small.icon,
svg.small.icons {
line-height: 1;
font-size: #small;
}
svg.icon,
svg.icons {
font-size: #medium;
}
svg.large.icon,
svg.large.icons {
line-height: 1;
vertical-align: middle;
font-size: #large;
}
svg.big.icon,
svg.big.icons {
line-height: 1;
vertical-align: middle;
font-size: #big;
}
svg.huge.icon,
svg.huge.icons {
line-height: 1;
vertical-align: middle;
font-size: #huge;
}
svg.massive.icon,
svg.massive.icons {
line-height: 1;
vertical-align: middle;
font-size: #massive;
}
/*******************************
Groups
*******************************/
svg.icons {
display: inline-block;
position: relative;
line-height: 1;
}
svg.icons .icon {
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
margin: 0em;
margin: 0;
}
svg.icons .icon:first-child {
position: static;
width: auto;
/* height: auto; */
vertical-align: top;
transform: none;
margin-right: #distanceFromText;
}
/* Corner Icon */
svg.icons .corner.icon {
top: auto;
left: auto;
right: 0;
bottom: 0;
transform: none;
font-size: #cornerIconSize;
text-shadow: #cornerIconShadow;
}
svg.icons .top.right.corner.icon {
top: 0;
left: auto;
right: 0;
bottom: auto;
}
svg.icons .top.left.corner.icon {
top: 0;
left: 0;
right: auto;
bottom: auto;
}
svg.icons .bottom.left.corner.icon {
top: auto;
left: 0;
right: auto;
bottom: 0;
}
svg.icons .bottom.right.corner.icon {
top: auto;
left: auto;
right: 0;
bottom: 0;
}
svg.icons .inverted.corner.icon {
text-shadow: #cornerIconInvertedShadow;
}

CSS Sliding views with ui-router

I am trying to achieve the same effect of sliding in/out views as found here:
http://dfsq.github.io/ngView-animation-effects/app/#/page/1
Ive created a plunker: http://plnkr.co/edit/ST49iozWWtYRYRdcGGQL?p=preview
But my entire ui-view completely disappears when i copy the CSS from the link above and think it could be down to the position: relative in my container
CSS:
*,
*:after,
*:before {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
html {
font-size: 62.5%;
min-height: 100%;
position: relative;
}
html body {
font-size: 140%;
line-height: 1.5;
margin: 0;
padding: 0 0;
margin-bottom: 60px;
}
.container {
max-width: 430px;
margin: 0 auto;
position: relative;
display: block;
float: none;
overflow: hidden;
}
.l-one-whole {
width: 100%;
}
form {
background: #f0f0f0;
height: 350px;
padding: 10px;
font-size: 1.4em;
}
CSS needed to add:
.slide {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
.slide.ng-enter,
.slide.ng-leave {
-webkit-transition: all 1s ease;
transition: all 1s ease;
}
.slide.ng-enter {
left: 100%;
}
.slide.ng-enter-active {
left: 0;
}
.slide.ng-leave {
left: 0;
}
.slide.ng-leave-active {
left: -100%;
}
HTML:
<body ng-controller="MainCtrl">
<ul>
<li>view1
</li>
<li>view2
</li>
</ul>
<main class="l-one-whole">
<section class="container">
<article class="l-one-whole">
<div ui-view class="slide"></div>
</article>
</section>
</main>
</body>
JS:
var app = angular.module('plunker', ['ui.router', 'ngAnimate']);
app.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('view1', {
url: '/view1',
templateUrl: 'page1.html'
})
.state('view2', {
url: '/view2',
templateUrl: 'page2.html'
});
$urlRouterProvider.otherwise('/view1');
});
Any help appreciated.
I think this is what you are looking for: Plunkr
I added the following styles to make animations work:
/* Transition effects */
.l-one-whole {
position: relative;
overflow: hidden;
min-height: 400px;
}
.slide {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.slide.ng-enter,
.slide.ng-leave {
transition: all 1s ease;
}
.slide.ng-enter {
transform: translate(100%, 0);
}
.slide.ng-enter-active {
transform: translate(0, 0);
}
.slide.ng-leave {
transform: translate(0, 0);
}
.slide.ng-leave-active {
transform: translate(-100%, 0);
}
I used transform instead of left because AFAIK it enables browser to accelerate animation using GPU increasing performance.
I hope I am not missing anything.
Result: http://plnkr.co/edit/vhGSiA?p=preview
I have use Angular 1.3.15 instead of 1.2.9
Simplified HTML
<section class="container">
<div ui-view class="slide-left"></div>
</section>
and more CSS
.container {
overflow: hidden;
position: relative;
}
.slide-left.ng-enter, .slide-left.ng-leave {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
transition: transform .7s ease-in-out;
}
.slide-left.ng-enter {
z-index: 101;
transform: translateX(100%);
}
.slide-left.ng-enter.ng-enter-active {
transform: translateX(0);
}
.slide-left.ng-leave {
z-index: 100;
transform: translateX(0);
}
.slide-left.ng-leave.ng-leave-active {
transform: translateX(-100%);
}
form { /* contents within ui-view */
position:absolute;
}
Change
<script src="https://raw.github.com/dlukez/ui-router/angular-1.2/release/angular-ui-router.js"></script>
to:
<script src="https://cdn.rawgit.com/dlukez/ui-router/angular-1.2/release/angular-ui-router.js"></script>
Updated plnkr
Detail explaination can be found here:
Link and execute external JavaScript file hosted on GitHub

Resources