Fully Furnished

Developer
Size
3,613 Kb
Views
10,120

How do I make an fully furnished?

A prototype experimenting placing objects overlaying an image.. What is a fully furnished? How do you make a fully furnished? This script and codes were developed by Coran Spicer on 15 October 2022, Saturday.

Fully Furnished Previews

Fully Furnished - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Fully Furnished</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="bare-floorplan"> <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/23594/rough-draft-bare-floorplan.jpg" />
</div>
<form id="add-furniture"> <select id="furniture-selection"></select> <a href="#">Add piece of Furniture</a>
</form>
<script> var furnitureJSON = {'furniture' :[ {"name":"Bed", "src":"https://s3-us-west-2.amazonaws.com/s.cdpn.io/23594/bed.png"}, {"name":"Chaise", "src":"https://s3-us-west-2.amazonaws.com/s.cdpn.io/23594/chaise.png"}, {"name":"Dresser", "src":"https://s3-us-west-2.amazonaws.com/s.cdpn.io/23594/dresser.png"}, {"name":"Floor Vase", "src":"https://s3-us-west-2.amazonaws.com/s.cdpn.io/23594/floor-vase.png"}, {"name":"Large Chest", "src":"https://s3-us-west-2.amazonaws.com/s.cdpn.io/23594/large-chest.png"}, {"name":"Night Stand", "src":"https://s3-us-west-2.amazonaws.com/s.cdpn.io/23594/night-stand.png"}, {"name":"Vanity", "src":"https://s3-us-west-2.amazonaws.com/s.cdpn.io/23594/vanity.png"}
]};
</script> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://code.interactjs.io/interact-1.2.2.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Fully Furnished - Script Codes CSS Codes

.bare-floorplan { display: block; position: relative; overflow: hidden; width: 100%;
}
.bare-floorplan img { display: block; position: relative; margin: 0 auto;
}
.bare-floorplan img.draggable-furniture { display: block; position: absolute; top: 0; left: 0; -moz-transform: translate3d(0, 0, 0); -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0);
}
#add-furniture { position: absolute; top: 5%; right: 5%; padding: 1rem; background-color: darkorange;
}
#add-furniture a { display: inline-block; font-family: sans-serif; text-decoration: none; color: lemonchiffon; font-size: .8rem;
}
#add-furniture a:hover { color: white;
}

Fully Furnished - Script Codes JS Codes

'use strict';
// prototype of a floorplan with placeable furniture
// uses interact.js http://interactjs.io
// create a select from the furniture json
var optionHTML;
var furnitureCollection = furnitureJSON.furniture;
for ( var piece in furnitureCollection ) { optionHTML += '<option value=' + furnitureCollection[piece].src + '>' +furnitureCollection[piece].name + '</option>';
}
$('#furniture-selection').html(optionHTML);
$('#add-furniture a').on('click', function(e){ e.preventDefault(); var currentPiece = $('#furniture-selection').val(); var uniqueID = createUID(); $('<img/>', { 'src' : currentPiece, 'class' : 'draggable-furniture', 'id' : uniqueID, 'data-top' : 0, 'data-left' : 0, 'data-rotate' : 0 }) .appendTo( '.bare-floorplan' ); // set up draggable interact('#'+uniqueID).draggable({ inertia: true, restrict: { restriction: "parent", endOnly: true, elementRect: { top: 0, left: 0, bottom: 1, right: 1 } }, ondoubletap: function (e) { e.preventDefault(); console.log( 'rotate me!' ); }, onmove: function(e) { var target = e.target, // keep the dragged position in the data-x/data-y attributes x = (parseFloat(target.getAttribute('data-x')) || 0) + e.dx, y = (parseFloat(target.getAttribute('data-y')) || 0) + e.dy; target.style.webkitTransform = target.style.transform = 'translate(' + x + 'px, ' + y + 'px)'; target.setAttribute('data-x', x); target.setAttribute('data-y', y); } }); /* going to have to use greensock for the translation and rotations because transform needs a matrix definition! .on('doubletap', function (e) { var target = e.target; e.preventDefault(); var dataDeg = target.getAttribute('data-rotate'); console.log( dataDeg ); var currentDeg = dataDeg.substring( 0, dataDeg.indexOf('deg') ); var newDeg = ( currentDeg + 90 ) === 360 ? 0 : currentDeg + 90; target.style.webkitTransform = target.style.transform = 'rotate('+newDeg+'deg)'; }); */
});
function createUID() { var text = ''; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; for( var i=0; i<5; i++ ) text += possible.charAt(Math.floor(Math.random() * possible.length)); return text;
}
Fully Furnished - Script Codes
Fully Furnished - Script Codes
Home Page Home
Developer Coran Spicer
Username cgspicer
Uploaded October 15, 2022
Rating 3
Size 3,613 Kb
Views 10,120
Do you need developer help for Fully Furnished?

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!

Coran Spicer (cgspicer) Script Codes
Create amazing marketing copy with AI!

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!