What's the scoop on ng-animate and personalized directives?

How can I add custom animation to my custom directive successfully?


.directive('home', function ($animate) {
  return {
      templateUrl: 'views/pantone-inner-home.html',
      restrict: 'AE',
      link: function postLink($scope, element, $parent) {
          var parentElement = element[0].parentElement;
          var afterElement = element[0].parentElement;
          $animate.enter(element, parentElement, afterElement);
                $scope.PrevNext = 'open';
                $scope.mainmenulink = '';
                $('.top_left_logo.white  img').css('position', 'fixed');
                $('#focus_force').focus();
      }
    };
});

I have a custom toggled ng-include that calls this in:


        <a ng-click="closemenulink(element)"  ng-href="#/services"><home class="pantone-ani"></home></a>

Everytime the ng-include includes this into the template, I receive the error message:


TypeError: Object [object HTMLAnchorElement] has no method 'after'

Why does this happen and what is needed here? I'm referring to: http://docs.angularjs.org/api/ngAnimate.$animate

PANTONE INNER HOME:


  <div ng-click="pantone()" class="pantone_wrap_outer blue slide_bottom">
    <div  class="pantone_wrap_inner blue">
      <div class="pantone blue">
        <img src="images/services.png" alt="">
      </div>
    </div>
  </div>

I am attempting to create animated menus using this setup. However, when I use ng-include to add these pantones (there are 4), the animations become disrupted after being opened and closed once. It seems that after the second load, the "ng-enter" class is not added from the $templateCache, causing issues with my animations.

Answer №1

Here is a link to the plunker I mentioned:

http://plnkr.co/edit/v8aCQI59reemfiEwXICC?p=preview

You may find that the afterElement is null for you since there are no siblings with the element.

Please take a look at the plunker and feel free to reach out if you have any further questions.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Sizing of Info Windows for Google Map Markers

I've been trying to create a Google map displaying multiple locations, but I can't seem to figure out how to adjust the size of the infowindow for each marker. I've spent several hours on this with no luck. Can anyone show me where in this f ...

Error message displayed: "An error occurred while processing the VueJS InertiaJS Uncaught (in promise) TypeError. It seems that the property 'search'

Currently, I am working on a Vue JS project with Inertia. One of the features I am implementing is a list that allows users to filter by name. data() { return { selectedUser: this.value, selected: null, search: & ...

Fetching data from a URL using AngularJS while the view is being loaded

Struggling to perform an API call when loading a specific view. controllers.controller("detailsCtrl", ["$scope", "$routeParams", "$filter", "$http", function($scope, $routeParams, $filter, $http) { $scope.getCurrent = function(url, id, callBack, apiCal ...

The numerical value fluctuates upon utilizing JSON.parse( )

I am currently utilizing Node/Express to send API requests to the unofficial Vine API. The data returned by the GET https://api.vineapp.com/users/search/ route undergoes changes during parsing. This is my code snippet: request({ url: 'https://api.v ...

Efficient State Management with React-Redux for Streamlined HTTP Requests

In the process of developing a React-Redux application, I have encountered a situation where I need to display a cancel button while a specific HTTP request is ongoing. Upon successful execution of the request, the UI should display the results. If the use ...

Hide the first dot indicator on the carousel when it is clicked

I've been experiencing a strange issue with my carousel - whenever I click on any of the dots, dot1 disappears. Upon inspecting the CSS, I found out that when clicking on a dot, it receives a display:none property from somewhere. Here is the code for ...

Activate the radio button upon page load in angularjs

<div class="form-group" style="margin-top: 20px;" ng-repeat="row in skuDetails"> <label class="checkbox-inline"> <input type="radio" name="amount_{{$index}}" value="amount" ng-model="row.amount" ng-checked="row.reductionAmount != &apos ...

What is the best way to incorporate JavaScript files into a Java application?

Java applications execute Javascript code. However, the Jquery library is too lengthy to be accommodated in a String variable. I am able to read jquery.js from a file but unsure of how to bundle it within a .jar file. ...

AngularJS is throwing an error because it is unable to access the property `$valid` on an undefined object

I am currently working on a web application using AngularJS and I have created the following form: <form name="form2" novalidate><multiselect class="input-xlarge" multiple="true" ng-model="selectedCar" options="c.name for c in cars" change="selec ...

Creating dynamic HTML and CSS in ASP.NET: A step-by-step guide

I am currently working on integrating a photo album in my asp.net website. I have been able to successfully display 3 images from a specific album by selecting their URLs from the database. However, I am facing an issue when a user has multiple albums. I n ...

An element generated through JavaScript fails to display on the webpage

As I navigate through the code with a foreach() loop, my goal is to generate a new div every time a firebase document containing the user's email is encountered. The script involves a blend of react js and javascript as I am still learning the ropes o ...

Tips for stopping the Print dialog box in Mozilla when using the CTRL + P shortcut

When I press CTRL + P on my view, a JavaScript code is triggered. The code works perfectly on all browsers except Mozilla; I cannot seem to block the Print Dialogue on that browser. Is there something wrong with my code? I have been attempting to implemen ...

Change the color of a specific day on the Arshaw Calendar using CSS

Can anyone help me with changing the color of the box in the month view in the arshaw calendar? I've been attempting to do so using this script, but my lack of expertise in javascript is proving to be a hurdle. The goal is for this script to be called ...

Connecting an HTML page to a JavaScript file in Framework7: A Step-by-Step Guide

Looking for help with linking an HTML page to a JavaScript file in Framework7. Here's a snippet of the HTML file: <div class="page-content" id="details-form"> ... </div> This form captures data, and I need ...

Geometry is making its debut appearance in ThreeJS for the very first time!

Currently, I am experimenting with a simple script using ThreeJS to create a point wherever you click on the screen. Below is the function responsible for adding the point: function addPoint(coord){ var geometry = new THREE.BufferGeometry(); var verti ...

Scripts are only able to close the windows that they themselves have opened as a way to work around

I have been utilizing the reactjs popup library and incorporated the following code: <Popup trigger={<a href="javascript:void(0)">bobby</a>} modal> <button className="close" onClick={close}> &time ...

Implement a 'mock' singleton decorator for the Node class that includes a required initialization method

(Disclaimer: Previous question was deleted due to new fundamental problems, so attempting again with a more logical question). I have a class that requires specific initialization properties: var CustomRequest = require('./request'), ok = r ...

Is it advisable to alter the prototype of String in JavaScript?

As I was in the process of creating a trim function in JavaScript, I decided to do some research before reinventing the wheel. After a quick Google search, I stumbled upon this helpful link: The solution provided on the website is as follows: String.prot ...

Kendo Grid with locked height

Using a grid with some elements locked, we have established a CSS-defined minimum and maximum height for the grid. .k-grid-content { max-height: 400px; min-height: 0px; } An issue arises when setting the height of the locked grid. If the grid&a ...

Setting a default date dynamically for v-date-picker in the parent component, and then retrieving the updated date from the child component

I'm working with a custom component that utilizes the v-date-picker in various instances. My goal is to have the ability to dynamically set the initial date from the parent component, while also allowing the date to be modified from the child componen ...