Skip to content

Instantly share code, notes, and snippets.

{"lastUpload":"2021-03-29T07:01:18.324Z","extensionVersion":"v3.4.3"}
@ydeshayes
ydeshayes / udt-dragndrop.js
Created May 26, 2018 12:55
Drag and drop directive
//This service and directive are a complete system of drag'n drop. This system drag and drop not only the html element
//but also the data of the ngModel where the draggable directive is added in the droppable ngModel
//The service is use to share the data between the two directives (draggable, droppable)
angular.module('dragndropServices', []).factory('dragndropService', function($rootScope) {
dragndropService = {
draggedData : {},
setDraggedData : function(data){
this.draggedData = data;
},
getDraggedData : function(){
@ydeshayes
ydeshayes / Setting scroll position with ReactJS
Last active November 16, 2021 15:42
Setting scroll position with ReactJS
// Edit from http://blog.vjeux.com/2013/javascript/scroll-position-with-react.html
componentDidMount() {
const node = ReactDOM.findDOMNode(this);
node.scrollTop = node.scrollHeight;
}
componentWillUpdate: function() {
const node = this.getDOMNode();
this.shouldScrollBottom = node.scrollTop + node.offsetHeight === node.scrollHeight;
},