Chat
How do I make an chat?
What is a chat? How do you make a chat? This script and codes were developed by Rahul Kumar on 14 October 2022, Friday.
Chat - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Chat</title> <meta name='viewport' content='width=device-width'/> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="explain">Drag n drop chat heads like Facebook Messenger</div>
<div class="thing" data-drag="data-drag"> <div class="circle"></div>
</div>
<div class="magnet-zone"> <div class="magnet"></div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://threedubmedia.com/inc/js/jquery.event.drag-2.2.js'></script> <script src="js/index.js"></script>
</body>
</html>
Chat - Script Codes CSS Codes
.thing, .thing .circle, .magnet { border-radius: 50%; width: 60px; height: 60px;
}
.thing .circle, .magnet-zone { -webkit-backface-visibility: hidden; backface-visibility: hidden; -webkit-perspective: 1000; perspective: 1000; -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0);
}
.explain { position: absolute; left: 0; right: 0; top: 50%; -webkit-transform: translateY(-50%); transform: translateY(-50%);
}
html { height: 100%;
}
body { width: 100%; height: 100%; overflow: hidden; text-align: center; font-family: 'Open Sans', 'Lato', 'Helvetica Neue', Arial, sans-serif;
}
* { -webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent; /* For some Androids */
}
.thing { position: absolute; -webkit-transform: translate(0, 0); transform: translate(0, 0); margin: 0px; cursor: pointer;
}
.thing .circle { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: #888; background-image: url(https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-xlt1/v/t1.0-9/14183818_2091096344449910_9077917389817409202_n.png?oh=2a409aaf4dfcafb23e172e31d8113afb&oe=583ADA14&__gda__=1480116016_ba3d12f887cf63746f2ca616b68ee845); background-size: contain; background-repeat: no-repeat; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); -webkit-transform: scale(1); transform: scale(1); -webkit-transition: -webkit-transform 50ms linear; transition: -webkit-transform 50ms linear; transition: transform 50ms linear; transition: transform 50ms linear, -webkit-transform 50ms linear;
}
.thing.transition { -webkit-transition: -webkit-transform 150ms cubic-bezier(0.175, 0.885, 0.145, 1.25); transition: -webkit-transform 150ms cubic-bezier(0.175, 0.885, 0.145, 1.25); transition: transform 150ms cubic-bezier(0.175, 0.885, 0.145, 1.25); transition: transform 150ms cubic-bezier(0.175, 0.885, 0.145, 1.25), -webkit-transform 150ms cubic-bezier(0.175, 0.885, 0.145, 1.25);
}
.thing.edge { -webkit-transition: all 400ms cubic-bezier(0.175, 0.885, 0.345, 1.1); transition: all 400ms cubic-bezier(0.175, 0.885, 0.345, 1.1);
}
.magnet-zone { pointer-events: none; -webkit-transition: -webkit-transform 300ms cubic-bezier(0.175, 0.885, 0.145, 1.32); transition: -webkit-transform 300ms cubic-bezier(0.175, 0.885, 0.145, 1.32); transition: transform 300ms cubic-bezier(0.175, 0.885, 0.145, 1.32); transition: transform 300ms cubic-bezier(0.175, 0.885, 0.145, 1.32), -webkit-transform 300ms cubic-bezier(0.175, 0.885, 0.145, 1.32);
}
.magnet-zone { position: absolute; text-align: center; bottom: 10px; padding: 10px 20px; left: 50%; -webkit-transform: translate(-50%, 100%) translateZ(0); transform: translate(-50%, 100%) translateZ(0);
}
.magnet-zone.overlap .magnet { -webkit-transform: scale(1.1) translateZ(0); transform: scale(1.1) translateZ(0);
}
.touching .circle { -webkit-transform: scale(0.9) translateZ(0); transform: scale(0.9) translateZ(0);
}
.moving .magnet-zone { -webkit-transform: translate(-50%, 0) translateZ(0); transform: translate(-50%, 0) translateZ(0);
}
.magnet-zone:after { content: '\00d7'; position: absolute; left: 0; right: 0; top: 50%; -webkit-transform: translateY(-50%) translateZ(0); transform: translateY(-50%) translateZ(0); text-align: center; font-size: 2em; font-weight: 100; color: #fff;
}
.magnet { background: rgba(0, 0, 0, 0.3); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); position: relative; -webkit-transform-origin: center; transform-origin: center; -webkit-transition: -webkit-transform 200ms cubic-bezier(0.175, 0.885, 0.145, 1.15); transition: -webkit-transform 200ms cubic-bezier(0.175, 0.885, 0.145, 1.15); transition: transform 200ms cubic-bezier(0.175, 0.885, 0.145, 1.15); transition: transform 200ms cubic-bezier(0.175, 0.885, 0.145, 1.15), -webkit-transform 200ms cubic-bezier(0.175, 0.885, 0.145, 1.15); -webkit-transform: scale(0.8) translateZ(0); transform: scale(0.8) translateZ(0); border: 2px solid #fff;
}
Chat - Script Codes JS Codes
var draggableEl = document.querySelector('[data-drag]'), magnet = document.querySelector('.magnet-zone');
function isOverlapping(el1, el2) { var rect1 = el1.getBoundingClientRect(), rect2 = el2.getBoundingClientRect(); return !( rect1.top > rect2.bottom || rect1.right < rect2.left || rect1.bottom < rect2.top || rect1.left > rect2.right );
}
function moveToPos(x, y) { var el = draggableEl; // finally apply the x, y to the top, left of the circle el.style.transform = 'translate(' + Math.round(x, 10) + 'px, ' + Math.round(y, 10) + 'px) translateZ(0)'; el.style.webkitTransform = 'translate(' + Math.round(x, 10) + 'px, ' + Math.round(y, 10) + 'px) translateZ(0)';
}
function moveMagnet(x, y) { var dist = 12, width = $('body').width() / 2, height = $('body').height(), direction = x > width ? 1 : -1, percX = x > width ? (x - width) / width : -(width - x) / width, percY = Math.min(1, (height - y) / (height / 2)); magnet.style.marginLeft = Math.round(dist / 1.5 * percX) + 'px'; magnet.style.marginBottom = Math.round(dist * percY) + 'px';
}
function move(event) { var el = draggableEl, //overlapping = isOverlapping(el, magnet), magnetRect = magnet.getBoundingClientRect(), elRect = el.getBoundingClientRect(); x = this._posOrigin.x + event.pageX - this._touchOrigin.x; y = this._posOrigin.y + event.pageY - this._touchOrigin.y; moveMagnet(x + (elRect.width / 2), y + (elRect.height / 2)); $('body').addClass('moving'); var touchPos = { top: y, right: x + elRect.width, bottom: y + elRect.height, left: x }; overlapping = !( touchPos.top > magnetRect.bottom || touchPos.right < magnetRect.left || touchPos.bottom < magnetRect.top || touchPos.left > magnetRect.right ); if (overlapping) { // center the circle in the magnetic zone var mx = (magnetRect.width / 2) + magnetRect.left; var my = (magnetRect.height / 2) + magnetRect.top; x = mx - (elRect.width / 2); y = my - (elRect.height / 2); if (!$(el).hasClass('overlap')) { $(el).addClass('transition'); setTimeout(function() { $(el).removeClass('transition'); }, 150); } magnet.className = magnet.className.replace(' overlap', '') + ' overlap'; el.className = el.className.replace(' overlap', '') + ' overlap'; } else { if ($(el).hasClass('transition')) { $(el).removeClass('transition'); } if ($(el).hasClass('overlap')) { $(el).addClass('transition'); setTimeout(function() { $(el).removeClass('transition'); }, 100); } magnet.className = magnet.className.replace(' overlap', ''); el.className = el.className.replace(' overlap', ''); } moveToPos(x, y);
};
$(draggableEl) .on('touchstart mousedown', onTouchStart) .on('touchmove drag', move) .on('touchend mouseup', onTouchEnd);
function onTouchStart(event) { var rect = this.getBoundingClientRect(); $('body').addClass('touching'); $(this).removeClass('edge transition'); this._touchOrigin = { x: event.pageX, y: event.pageY }; this._posOrigin = { x: rect.left, y: rect.top };
}
function onTouchEnd(event) { var el = draggableEl, rect = el.getBoundingClientRect(), width = $('body').width(), halfScreen = width / 2; if (!$(el).hasClass('overlap')) { $('body').removeClass('moving touching'); magnet.style.marginBottom = magnet.style.marginLeft = '0px'; var x = (rect.left + (rect.width / 2)) < halfScreen ? -10 : width + 10 - rect.width; $(el).addClass('edge'); moveToPos(x, rect.top); setTimeout(function() { $(el).removeClass('edge'); }, 500); }
}
moveToPos(($('body').width()/2) - 30, 10);
Developer | Rahul Kumar |
Username | rk007 |
Uploaded | October 14, 2022 |
Rating | 3 |
Size | 5,136 Kb |
Views | 44,528 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Bitch Roxana | 2,983 Kb |
Shake it | 2,486 Kb |
By Rahul | 3,652 Kb |
Coffee | 2,681 Kb |
For you | 6,495 Kb |
Hey | 4,289 Kb |
- | 2,286 Kb |
HeartIt | 2,039 Kb |
Smile | 3,967 Kb |
Hmmm... | 4,848 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Cake | Kennyname | 7,220 Kb |
Wikipedia Viewer | Codinger | 4,681 Kb |
Reading Grid | Tappily | 4,306 Kb |
Android Play Store With Slick Carousel | -J0hn- | 4,982 Kb |
A Pen by Dalton Liu | Liudalton | 12,437 Kb |
Welcome | Nakome | 6,076 Kb |
Emberjs Bootstrap Modal Carousel | Somethingkindawierd | 4,233 Kb |
Eunice A | Ejbronze | 2,203 Kb |
Project MMetro beta | Atomicsong | 5,157 Kb |
Slider | Mohammed-fawzy | 2,634 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!